Hey all,
I'm deep into pset5, and for the most part it has been going well. I'm putting together my "check function," and one of the barriers I've come across is that strcasecmp(), which is what the video and instructions say to use, does not appear to work when the words have apostrophes in them. The program compiles but "freezes up" when attempting to run it. I have to do a ctrl + c to kill the program, otherwise it appears to "freeze/hang" indefinitely. I tried on different software as well and the same result occurred. Even when I tried to run debug50 to try and access the problem more fully, I couldn't even get it to open; the program just freezes.
I tried searching Google, forums, stackoverflow, etc., but couldn't find anything about comparing words with apostrophes in them. I also have not been able to fix this freezing issue. Based on the documentation for strcasecmp(), it doesn't appear that it works with symbols, which might explain why I'm having this issue.
My initial thought is to just write my own function to compare the words and make sure apostrophes are included. That way I avoid this issue...But, since the instructions say to use strcasecmp(), I wanted to reach out and see if you guys have any thoughts/advice on this before I spend all that time and effort writing my own function. I want to make sure I'm not missing something simple...
I'm not looking for someone to spoil the pset; just looking for some help on this annoying issue! :0
EDIT 1: I believe the freezing issue has to do with my particular piece of code. I did some testing on a different, stripped down program and strcasecmp() does appear to work with apostrophes. So I just need to figure out what portion of my code is making it freeze when I add in the apostrophe...If anyone has any ideas, would love to hear 'em!
EDIT 2: So doesn't look like it has anything to do with strcasecmp() at all actually. It has to do with argv[]. Whenever passing a word with an apostrophe in it, e.g., children's, the program freezes. If I pass it a word without an apostrophe, e.g., children, the program doesn't freeze. Here's the simple program I used to test this:
int main(int argc, char *argv[])
printf("%s\n", argv[1]);
return 0;Not sure why argv makes the program freeze with an apostrophe...Thoughts?
Strcasecmp not working in Pset 4
strcasecmp not working in speller
strcasecmp is unvalid in c99
You need to read the entire error - strcasecmp is not invalid, the implicit declaration of it is invalid. Basically, this means you're trying to use a function without having declared it.
Make sure you've included the correct header for strcasecmp (strings.h)
Why is the strcasecmp() function not working properly (line 39) or am I doing something incorrectly?
What hash function are you using? If your hash function is case sensitive it won't matter that you're using strcasecmp since you'll be searching the wrong index.