Questions tagged [strcmp]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
2 answers

Week 4 lecture: can't reproduce string != string

In the lecture of week 4 in CS50x, David illustrates how two strings can't be compared with two equal signs (==), and instead, strcmp() has to be used. I can't reproduce this locally or on CS50's IDE ...
therubberduck's user avatar
0 votes
1 answer

pset3, vote(); direct comparison failing but strcmp() working?

Why is if (strcmp(candidates[i], name) == 0) working, but: if (name == candidates[i]) not working? I have also tried with casting string on both sides, but doesn't work. I have checked via printf, ...
Eren Turgut's user avatar
0 votes
1 answer

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 &...
reham501's user avatar
0 votes
1 answer

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])...
David Stammerjohn's user avatar
0 votes
1 answer

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"); } } ...
Lara Corika's user avatar
0 votes
1 answer

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

I don't understand what's missing or what's wrong.
Stark Arpit's user avatar
1 vote
1 answer

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 ...
number9's user avatar
  • 111
1 vote
1 answer

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)...
Kypore's user avatar
  • 13
0 votes
1 answer

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 ...
Jon Levin's user avatar
1 vote
1 answer

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 ...
JV305's user avatar
  • 29