Comparing a TCHAR to "whatever" not working
Nov 23, 2012 at 5:18am UTC
Im trying to have a while loop go through until a TCHAR variable is = "name" but after the loop completes it reports back that it was never = to *name* but after going back through the list it clearly was. My loop is-
1 2 3 4 5 6 7 8 9 10 11 12 13
while (me32.szModule != "client.dll" ){
cout << me32.szModule << endl;
Module32Next(snapshot,&me32);
if (me32.szModule == "client.dll" ){
cout << "Found: " << me32.modBaseAddr << endl;
system("PAUSE" );
}
else if (GetLastError() == ERROR_NO_MORE_FILES){
cout << "client.dll Not Found" << endl;
system("PAUSE" );
exit(1);
}
}
Taken from a file i wrote out the results too, its clearly listed but its saying its not.
client.dll
Nov 23, 2012 at 6:07am UTC
me32.szModule != "client.dll"
This code is comparing some pointers, not the C-strings they are pointing to. Either convert them to an std::string or just use strcmp.
Nov 23, 2012 at 6:28am UTC
Thanks.
Topic archived. No new replies allowed.