Originally Posted by
yeller
Finally, what did you mean by "I suspect you may have a '\0' problem with var2."?
Since a string in C is basically a block of contiguous sequence of chars that are ended with a '\0', I meant that you may not have a '\0' at the intended place in var2, thereby making all functions continue processing past the end of the string until coming across a '\0' later on.
If you have a block of memory like this:
Code:
'H', 'i', '!', '\n', '\0', 'h', 'y', '5', 'f', 's', '\0', 'x'
And the string starts at the first char, then the string should be "Hi!\n". If, however, you lose the first '\0' -- let's say it got overwritten with another '\n', then you'll have this interpretted as the string: "Hi!\n\nhy5s". Obviously not what you meant.