• Wed. Dec 7th, 2022


Latest Software News and Hacks

strcasecmp() seems to create an infinite loop


May 31, 2022


I am working on a program for CS50, and I have to check if a word is in a list of nodes. When I use strcasecmp() to see if the word is in the list, I seem to get an endless loop. I don’t get any error messages or anything but my code never stops and when I use the debugger I seem to be stuck at the strcasecmp() line.


// Returns true if word is in dictionary, else false bool check(const char *word) { // TODO node *temp = malloc(sizeof(node)); int index = hash(word); temp = table[index]; while (temp != NULL) { if (strcasecmp(temp->word, word) == 0) //seems to be stuck here { //free(temp); return true; } temp = temp->next; } return false; } 

Can anyone please help me?

Thank you so much!

submitted by /u/MUCU-
[link] [comments]

Go to Source of this post
Author Of this post: /u/MUCU-
Title Of post: strcasecmp() seems to create an infinite loop
Author Link: {authorlink}