Error message at runtime is:Code:if(temps[0] == 'l' && temps[1] == 'o' && temps[2] == 'o' && temps[3] == 'k') { int number = 0; int fix = 0; char searchstr[30],tempstr[35]; char lookmsg[100]; for(int y=0;y<30;y++) { if(y == 0 && temps[y+5] - '0' < 10) //if we are using a number to define the creature { fix = 2; } if(temps[y+5] == ' ') //if we are done { searchstr[y-fix] = '\0'; break; } else //if not next character in { searchstr[y-fix] = temps[y+5]; } } strcpy(tempstr," "); strcat(tempstr,searchstr); strcpy(searchstr,tempstr); if(0 <= (temps[5] -'0') && (temps[5] -'0') <= 9) //is it a number? { for(int x=0;x<LNPCS;x++) { if(npcs[x].IsHere() == Players[ID].IsHere() && strcmp(npcs[x].GetName(),searchstr) == 0) { number++; if(number == (temps[5] -'0')) { npcs[x].MakeLookMsg(lookmsg); cons[ID].send((unsigned char)strlen("CHAT")); cons[ID].send("CHAT"); cons[ID].send((unsigned char)strlen(lookmsg)); cons[ID].send(lookmsg); } } } } else { for(int x=0;x<LNPCS;x++) { if(npcs[x].IsHere() == Players[ID].IsHere() && strcmp(npcs[x].GetName(),searchstr) == 0) { npcs[x].MakeLookMsg(lookmsg); cons[ID].send((unsigned char)strlen("CHAT")); cons[ID].send("CHAT"); cons[ID].send((unsigned char)strlen(lookmsg)); cons[ID].send(lookmsg); } } } }else
Stack around the variable 'tempstr' was corrupted.
I figure it is occuring when I try to add a leading space to the search string. I don't understand what is making me overstep the allocated memory. Not sure if using pointers will help the situation any either. Anyone have some advice for me?
edit:
LNPCS is the current number of npcs in the game forgot I had that in...



LinkBack URL
About LinkBacks



CornedBee