A Question..
m_belanger at mosaic.dec.com
m_belanger at mosaic.dec.com
Thu Aug 17 04:08:23 AEST 1989
In message # <1586 at sunset.MATH.UCLA.EDU> Tony writes:
>I seemed to have run into a strange problem in C that I can't quite
>figure out.
>I'm just trying to convert a time value stored in a long integer
>in the form 111753 into a more presentable format 11:17:53.
> ... (removed)
>In other words strcpy seems to be working fine but strncpy is doing
>something bizzare, or is it the way I'm strncpy'ing?
STRNCPY( d, s, n ) copies EXACTLY n bytes from s to d which doesn't place a
NULL character after the nth byte. When the STRNCAT routineis called it
appends the concatenated string at the end of the initial line.
Try clearing the string using a MEMSET before creating the next string.
Moe Belanger
More information about the Comp.lang.c
mailing list