4 Respuestas
26th Oct 2018, 8:21 PM
Vlad Serbu
Vlad Serbu - avatar
0
can you explain the sprintf?
27th Oct 2018, 9:49 AM
Sajad Rahmanian
Sajad Rahmanian - avatar
0
Sajad Rahmanian sprintf is similar to printf, but puts the output in a string instead of putting it on the terminal. We want the string to be "%ns", where the n is a decimal formated variable. As you probably know, printf uses %% to print a literal % and %d to print a decimal integer so we use sprintf(str, "%%%ds", n). If, for example n is 12, then str will be "%12s",and we can feed that to scanf to scan for a string of at most 12 characters.
27th Oct 2018, 10:25 AM
Vlad Serbu
Vlad Serbu - avatar
0
got it..thank you
27th Oct 2018, 12:57 PM
Sajad Rahmanian
Sajad Rahmanian - avatar