delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/29/11:55:04

Date: Sun, 29 Mar 1998 14:29:36 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Cloud Wu <cloudwu AT nease DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: cprintf() 's question
In-Reply-To: <351C6FD4.7393@nease.net>
Message-ID: <Pine.SUN.3.91.980329142751.15237T-100000@is>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019