The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 05-15-2008
jim mcnamara jim mcnamara is offline
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,865
What the OP is on about:

from the same C-99 standard (what POSIX uses)
Quote:
The snprintf function returns the number of characters that would have been written
had n been sufficiently large, not counting the terminating null character, or a neg ative
value if an encoding error occurred. Thus, the null-terminated output has been
completely written if and only if the returned value is nonnegative and less than n.
So you have to check the return code of snprintf to know if it worked correctly.
You should check return codes no matter how stupid it seems. If you use gcc then
Code:
gcc -Wall <filename.c>
or use lint on your code. The only acceptable compile is a completely clean one.
Reply With Quote