A question...
Shiping Zhang
ping at cubmol.BIO.COLUMBIA.EDU
Fri Aug 18 01:44:12 AEST 1989
In article <1025 at virtech.UUCP> cpcahil at virtech.UUCP (Conor P. Cahill) writes:
>
>Solution:
> 1. Place a null in str_time[2] after the strncpy().
> 2. Change the strncpy()s and strcats()s to a single sprintf as
> follows:
> sprintf(str_time, "%2s:%2s:%2s" local_str, local_str+2,
> local_str+4);
>
The second solution is wrong. %2s does not limit the number of
characters to 2. It only specifies the MINIMUM feild. If the length
of local_str is 6, then the length of str_time will be 12 after
sprintf().
-ping
More information about the Comp.lang.c
mailing list