Mail Archives: djgpp/1998/03/29/11:55:04
On Sat, 28 Mar 1998, Cloud Wu wrote:
> cprintf("%-*s",WIDTH,s);
> ...
>
> but, the left of my string s was cut. :-(
> The right part of the string was printed in the middle of screen.
> I remember, "%-*s" is to say leftjustify the output,
Strings printed with %s format are always left-justified, so you don't
need the `-' flag. And for %s format, the maximum number of
characters is given by the precision, not by width. So you need to
say this instead:
cprintf ("%.*s, WIDTH, s);
Btw, was the string in `s' null-terminated? If not, you can have all
kinds of weird effects. (Sorry for asking the obvious, but you didn't
post enough of your source to deduce the answer from there.)
- Raw text -