Hi All,
I was going through some C faqs online edition , where I saw a strange data formatter %.*s which I came across for first time , I would like to know how it works!
This question is in "comp.lang.c FAQ list · Question 13.2" which gives answer for "Why does strncpy not always place a '\0' terminator in the destination string?".
[HTML]"You can get around the problem by using strncat instead of strncpy. If the destination string starts out empty (that is, if you do *dest = '\0' first), strncat does what you probably wanted strncpy to do:
*dest = '\0';
strncat(dest, source, n);
This code copies up to n characters, and always appends a \0.
Another possibility is
sprintf(dest, "%.*s", n, source)
(though, strictly speaking, this is only guaranteed to work for n <= 509)."[/HTML]
Best regards..
Anil