c - Why is printf with a single argument (without conversion specifiers) deprecated? -


in book i'm reading, it's written printf single argument (without conversion specifiers) deprecated. recommends substitute

printf("hello world!"); 

with

puts("hello world!"); 

or

printf("%s", "hello world!"); 

can tell me why printf("hello world!"); wrong? written in book contains vulnerabilities. these vulnerabilities?

printf("hello world!"); imho not vulnerable consider this:

const char *str; ... printf(str); 

if str happens point string containing %s format specifiers, program exhibit undefined behaviour (mostly crash), whereas puts(str) display string is.

example:

printf("%s");   //undefined behaviour (mostly crash) puts("%s");     // displays "%s" 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -