-
byte routine not working
ok i am making a byte routine taht searches for a particular byte in a string of bytes. All the addresses of the found bytes are stored in an array. But its not working and i cant figure out why. Please tell me what i have done wrong:
Code:
char *cptr = strchr(bytebuffy, searchnum);
while(cptr != NULL)
{
int a = cptr - bytebuffy;
Addresses1[g_FoundCount + 1] = readbase + a;
g_FoundCount++;
cptr = strchr(bytebuffy + a, searchnum);
}
when this runs the windows program just hangs and stops responding as if the while loop wont stop looping :(
-
> int a = cptr - bytebuffy
And if this is 0, then
> cptr = strchr(bytebuffy + a, searchnum);
Is going to give you the same answer as last time
Restart your search from the character after the one you've just found.
-
It would be easier to do this using the string class.
-
Change this line:
Code:
cptr = strchr(bytebuffy + a, searchnum);
to
Code:
cptr = strchr(bytebuffy + a + 1, searchnum);