Please help me. I have been stuck here for many many hours now. It just seems that token never equals to line2 for some reason, when it supposed to. Is it because the token is in another format that is different from normal character?
Please help me and tell me why. Checker always = 0 in the following case(which means token never equals to line2).
char* token = strtok(text_str, " \n");
int checker = 0;
char line2[100000] = "";
while( token != NULL ) {
while(fgets(line2, 102, dictionary) != NULL){
if(strcmp(line2, token) == 0) {
checker++;
}
}
printf("%s\n", token);
printf(" %d\n", checker);
checker = 0;
token = strtok( NULL, " \n");
}
C programming question?
White space might be filling the extra space in the array. Try to trim line2 before the strcmp.
Because
"Happy " != "Happy"
pokemon cards
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment