Click here to Skip to main content
15,887,273 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: _tcscpy_s and unused buffer part Pin
David Crow28-Sep-16 18:09
David Crow28-Sep-16 18:09 
GeneralRe: _tcscpy_s and unused buffer part Pin
leon de boer28-Sep-16 18:14
leon de boer28-Sep-16 18:14 
GeneralRe: _tcscpy_s and unused buffer part Pin
David Crow29-Sep-16 3:10
David Crow29-Sep-16 3:10 
AnswerRe: _tcscpy_s and unused buffer part Pin
Joe Woodbury24-Oct-16 14:36
professionalJoe Woodbury24-Oct-16 14:36 
QuestionArrow Key use in MFC vc++ Application Pin
rajmohan 12327-Sep-16 2:38
rajmohan 12327-Sep-16 2:38 
AnswerRe: Arrow Key use in MFC vc++ Application Pin
Chris Losinger27-Sep-16 3:26
professionalChris Losinger27-Sep-16 3:26 
GeneralRe: Arrow Key use in MFC vc++ Application Pin
rajmohan 12327-Sep-16 20:05
rajmohan 12327-Sep-16 20:05 
QuestionHow do you get type from format? Pin
Vaclav_26-Sep-16 5:03
Vaclav_26-Sep-16 5:03 
I am learning how to use ellipsis in function.
Started with putting "int" as parameters, with first entry being count of parameters passed to he function.
Now I want to pass multiple types , not just int , to the function.
The following snippet will do, but...

How do you get "type" from passing a char * - in this case "format" variable?
What did I missed ?

Thanks for your help.
Vaclav

I am not sure if I tagged the code properly.


<pre lang="c++">
void my_printf( char *format, ... ) {
va_list argptr;

va_start( argptr, format );

while( *format != '\0' ) {
// string
if( *format == 's' ) {
char* s = va_arg( argptr, char * );
printf( "Printing a string: %s\n", s );
}
// character
else if( *format == 'c' ) {
char c = (char) va_arg( argptr, int );
printf( "Printing a character: %c\n", c );
break;
}
// integer
else if( *format == 'd' ) {
int d = va_arg( argptr, int );
printf( "Printing an integer: %d\n", d );
}

*format++;
}

va_end( argptr );
} </pre>
AnswerRe: How do you get type from format? Pin
Richard MacCutchan26-Sep-16 5:18
mveRichard MacCutchan26-Sep-16 5:18 
GeneralRe: How do you get type from format? Pin
Vaclav_26-Sep-16 6:12
Vaclav_26-Sep-16 6:12 
GeneralRe: How do you get type from format? Pin
Richard MacCutchan26-Sep-16 6:15
mveRichard MacCutchan26-Sep-16 6:15 
GeneralRe: How do you get type from format? Pin
leon de boer27-Sep-16 2:24
leon de boer27-Sep-16 2:24 
GeneralRe: How do you get type from format? Pin
Vaclav_2-Oct-16 5:30
Vaclav_2-Oct-16 5:30 
Questionhow to create thread on windows? Pin
Member 1118935723-Sep-16 19:49
Member 1118935723-Sep-16 19:49 
AnswerRe: how to create thread on windows? Pin
Richard MacCutchan23-Sep-16 22:46
mveRichard MacCutchan23-Sep-16 22:46 
AnswerHere's how! Pin
Software_Developer24-Sep-16 0:49
Software_Developer24-Sep-16 0:49 
GeneralRe: Here's how! Pin
Member 1118935724-Sep-16 1:16
Member 1118935724-Sep-16 1:16 
GeneralRe: Here's how! Pin
Richard MacCutchan24-Sep-16 3:46
mveRichard MacCutchan24-Sep-16 3:46 
GeneralRe: Here's how! Pin
Member 1118935724-Sep-16 3:55
Member 1118935724-Sep-16 3:55 
GeneralRe: Here's how! Pin
Richard MacCutchan24-Sep-16 4:05
mveRichard MacCutchan24-Sep-16 4:05 
GeneralRe: Here's how! Pin
Member 1118935724-Sep-16 4:19
Member 1118935724-Sep-16 4:19 
GeneralRe: Here's how! Pin
leon de boer24-Sep-16 7:37
leon de boer24-Sep-16 7:37 
GeneralRe: Here's how! Pin
Member 1118935724-Sep-16 10:52
Member 1118935724-Sep-16 10:52 
GeneralRe: Here's how! Pin
leon de boer24-Sep-16 16:43
leon de boer24-Sep-16 16:43 
GeneralRe: Here's how! Pin
Member 1118935724-Sep-16 19:55
Member 1118935724-Sep-16 19:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.