Gooblah
Heh...
- Joined
- Jun 5, 2007
- Messages
- 4,282
So, when one includes the string.h library in C++, one can use the strncmp function, which takes two strings, a length, and compares each character of one string to the corresponding one of the other, until the characters don't match, a null (/n) chara has been reached, or the length has been reached.
Something like this:
strncmp (const char* string 1, const char* string2, int length)
The function returns zero if all the characters up to the length specified match.
In a program I've written to add new tags to XML files (a hopeful boon for Civ4 modders!), I need to use the stncmp function to determine where to add the new tags. However, when I try to compile, I cannot get it to work. I'm inputting two char* arrays and an int value, but instead get an error like this:
Any ideas?
Something like this:
strncmp (const char* string 1, const char* string2, int length)
The function returns zero if all the characters up to the length specified match.
In a program I've written to add new tags to XML files (a hopeful boon for Civ4 modders!), I need to use the stncmp function to determine where to add the new tags. However, when I try to compile, I cannot get it to work. I'm inputting two char* arrays and an int value, but instead get an error like this:
Code:
invalid conversion from `char' to `const char*'
initializing argument 1 of `int strncmp(const char*, const char*, size_t)'
Any ideas?