C/C++??????????
???????????? ???????[ 2014/10/15 10:58:47 ] ??????????????? C++
???????????????????????????仯????????????????????????????仯????????int??double????????char*??????????????????????printf()??sprintf()??????????????????????????????????????????????????????????????????????????????д???????????C#????????????parame??????C??C++???????????????????????????????????????????????????????Щ??????
????????? ?????????
????????????…?????????printf()??????scanf()????????????
????int printf(const char *?? ...);
????int scanf(const char *?? ...);
??????????????????????κ?Variadic Macros????????????__VA_ARGS__???磺
????#define WriteLine(...) { printf(__VA_ARGS__); putchar('
');}
??????WriteLine("MoreWindows");
??????????printf()????????????????????????????????
????#define WriteLine (...) printf(__VA_ARGS__) + (putchar('
') != EOF ? 1: 0);
??????????????WriteLine?????????????????????????????????????’
’???????????i??j???????12??
????int i = WriteLine("MoreWindows");
????WriteLine("%d"?? i);
????int j = printf("%s
"?? "MoreWindows");
????WriteLine("%d"?? j);
????????? ??δ???va_list????
??????????????????????va_list???????????????????????????????β????????????
??????<stdarg.h>?п??????va_list????壺
????typedef char * va_list;
???????????????????е?????????????£?va_start()??va_end()??va_arg()??
?????????<stdarg.h>?п?????????????????壺
????#define va_start(ap??v) ( ap = (va_list)&v + _INTSIZEOF(v) )
????#define va_end(ap) ( ap = (va_list)0 )
????#define va_arg(ap??t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
?????????????_INTSIZEOF???????£?
????#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
?????????????????
????va_end(ap)??????????????ó?NULL??
????va_start(ap??v)??ap = (va_list)&v + _INTSIZEOF(v)?????v???????????_INTSIZEOF(v)??_INTSIZEOF(v)?е?С???????( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )???λ?????????????е??鷳?????????????????????????sizeof(int)??????sizeof(int)?4??1??2??3??4?4??5??6??7??8?8????x??n?????C??????????????((x+n-1)/n)*n????n?2?????????????????????λ????——???? n - 1????????λ?? 0???????
????va_arg(ap??t)???ap??????????t????????????????????????va_arg(ap?? int)?????????int?????????????????????
??????????????????va_start()?????ε?????????????va_arg()????????????????va_end()??β????????????????
?????????? vfprintf()??????vsprintf()????
????vfprintf()?????????????????????????????????????printf()?????к???????????ж??????汾???????????????
???????????
????int vfprintf(
????FILE *stream??
????const char *format??
????va_list argptr
????);
?????????????????FILE???FILE????C??????д????????????????????????stdout??
?????????????????????????
????????????????va_list???????????????????????char*??????β?????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11