Questions tagged [strcmp]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
940 views

Problem set 3 Plurality ISSUE cs50

I've been trying to solve the new problem set 3 plurality step by step, and here where I got stuck, but somehow I'm sure about my answer bool vote(string name) { bool v = false for (int i = 0 ; i &...
0
votes
1answer
21 views

Why does the strcmp() give 17 instead of 0 between the second characters of dave and baca

int main(void) { int i; char* kw = get_string(Enter keyword: \n"); char* plntext = get_string(Enter plaintext: \n); for(i = 0;i < strlen(kw); i++) { printf("%s, ", kw[i])...
0
votes
1answer
31 views

The purpose of 0 in strcmp

Can anyone please explain what is the purpose of 0 here? What 0 is doing? Why 0? if (strcmp == 0) { printf ("same\n"); } else { printf ("not the same\n"); } } ...
0
votes
1answer
80 views

What happens if strcmp() is assigned to int variable?

I don't understand what's missing or what's wrong.
1
vote
1answer
1k views

strcmp always returns 0, even with different strings. Week4

Working through the CS50 pages, I decided to do this locally on my Linux Mint computer (gcc --version gets me: gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4). At the start, I did not realize that cs50.c ...
1
vote
1answer
69 views

Pset6 parse getting error 501

So, I've finished parse except that whenever I run my code I get error 501 every time. I've figured out that it's also checking the next value in this condition if(strcasecmp (&path [0],"/") != 0)...
0
votes
1answer
141 views

strcmp does not return expected result

I'm working on my Load function in Pset5, and my current error seems to be the result of the strcmp not working as I expected. for(int i = 0; strcmp(&c, "\n") != 0; i++) In GDB I can see that ...
1
vote
1answer
508 views

why doesn't strcmp return 0 even though the strings look identical in gdb?

I don't understand why strcmp says these strings are different. In gdb they look identical. I can't figure it out and I have searched the forum and didn't have any luck. Please let me know if I can ...