Originally Posted by
127.0.0.1
Your solution doesn't work because the whole string is compared for the match, I need to know the index that the match is at so I can terminate the string if there is valid text before the comment.
Since StrStr returns a pointer to the first character in the matched string, you do know exactly where to plop your \0 to terminate the string with only a very slight modification.
Code:
bool KillCommentString(char *str)
{ char *cmt; // address of comment
cmt = strstr(str,Comment_Prefix);
if (!cmt)
return 0;
*cmt = 0; // terminate the string
return 1; }
No offense is intended, but I'm thinking you're still trying to make this whole new thing into the same old thing you already understand and, as I mentioned before, that's a mistake.