Re: simple printf question
Bint said:
> Hi,
>
> I have a giant string buffer, and I want to print out small chunks of it
> at
> a time. How do I print out, say 20 characters of a string?
>
> Is it like this?
>
> printf("%20s",mystring);
>
> I can change the start point of the string, I just don't know how to tell
> it to only print out X number of characters from it.
printf("%.20s", mystring);
Note the dot in the format specifier.
Covered in K&R2 p244.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
|