July 31st, 2013, 05:55 PM
Strings terminated by null
Could anyone please tell me why I need to terminate a string using a NULL character when I have specified how many characters it should read like:
July 31st, 2013, 06:11 PM
Because many of the string and I/O functions expect strings to be null terminated and you don't pass the length of your array to many of these functions.
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
July 31st, 2013, 06:41 PM
Another thing to consider is the implicit NUL terminator; your array size isn't large enough to hold it.
August 1st, 2013, 06:11 PM
Various functions need to know where the string ends !