Created
April 15, 2015 07:57
-
-
Save hkuno9000/57edb60ab0daa21f9ef9 to your computer and use it in GitHub Desktop.
TESTCODE: NULL is safe as a argument of printf("%s")
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
char buf[200]; | |
puts("*** test printf NULL"); | |
printf( "printf :%s,%S,%ws\n", NULL, NULL, NULL); | |
#ifdef _MSC_VER | |
sprintf_s(buf, "sprintf_s:%s,%S,%ws\n", NULL, NULL, NULL); puts(buf); | |
#endif | |
return 0; | |
} | |
/* | |
RESULT: VC9(vs2008) on Windows7 | |
*** test printf NULL | |
printf :(null),(null),(null) | |
sprintf_s:(null),(null),(null) | |
RESULT: gcc4.8.3 on cygwin | |
*** test printf NULL | |
printf :(null),(null),ws | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment