printf("%s", ...)
assumes null-terminated string. If I have a string deliminated by a length, what is the best way to do?
Suppose buf
is the start address of the string, n
is the length of the string. I have the following code. Is it the best way to do so?
for(int i=0;i<n;++i) {
fputc(buf[i], stdout);
}