I was under the impression strtok was supposed to return NULL when it hits the end of a string. It's not doing it when it should here. I'm testing with a multiline edit control with only 1 line of text (no \n). It continues into the loop a second time even though it shouldn't. Any ideas?
Code:
GetWindowText(hCode, txtCode, sizeof(txtCode));
ParseCodes(txtCode, strlen(txtCode)
int ParseCodes(char* code, int length)
{
u32 address[CODE_MAX_LINES], value[CODE_MAX_LINES], codevalue;
char type[CODE_MAX_LINES];
int i = 0, c = 0;
char *codeline, codepart[20];
length = RemoveChar(code, length, ' ');
codeline = strtok(code, "\n");
CheatDB.System = SYSTEM_N64;
while (codeline != NULL)
{
switch(CheatDB.System)
{
case SYSTEM_N64: case SYSTEM_PS1:
{
if (strlen(codeline) != 12) { return 0; }
if (!isHex(codeline)) { return 0; }
strncpy(codepart,codeline, 2); codepart[2] = '\0';
String2Hex(codepart, &codevalue);
c++;
} break;
}
codeline = strtok(NULL, "\n");
}
}