Hi, i am kind of new to c programming. So, i here want to get a clarification about boolean.
here is the part of the code:
Code:
scanf ("%s\n", name);
if (strcmp(name, "David") == 1)
printf (" You are David");
this code seem to be wrong according to the tutorial i learnt. What it wrote was (strcmp(name, "David") == 0). please explain to me. I understood that =0 means false. Therefore, it supposed to be 1.
Here is my second question :
Code:
char name[10] = "David";
OR
char name[10];
strcpy(name, "David");
which is the correct way to assign a string to an array?
by the way, my programming tutorial taught me to use the second one. It did not mention about the first one.