What is the maximum size which can be printed using %s
in c language.
I was trying to print a buffer in file using fprintf
but at a point I felt that it was going more to 320KB . And fprintf
was writing truncated string to the file . Is there any limit with %s
?
printf()
has an upper limit. It will successfully handle up to N char
s. N is at least 4095.
The number of characters that can be produced by any single conversion shall be at least
4095. C11dr §7.21.6.1 15
[Edit]
With such a large (320 kB) expected output, if possible, consider using fputs(s, stream)
rather than fprintf(stream, "%s", s);
which does not have this 4095 limitation.
Similar to
printf/fprintf maximum size according to c99