c - Comparing 2 strings and getting the error expected expression -


i working on project enter name , initials printed. when try compare strings "expected expression" error. doing wrong?

#include <stdio.h> #include <stdlib.h> #include <cs50.h> #include <string.h> #include <ctype.h>  int main(void) {    printf("name: ");    string name = getstring();    printf("\n");     int length = strlen(name);    string compair1 = " ";    for(int l = 0;l<=length;l++) {       char compair2 = name[l];       int  res = strcmp(compair1,&compair2);       if(res == 0) {          printf("found blank space");       }    } } 

  • if u jst want find space can this:

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h>  int main(void) {    printf("name: ");    char name[20];    gets(name);    printf("\n");    int length = strlen(name);   for(int l = 0;l < length;l++)   {       if(name[l] == ' ')       printf("found blank space");   } } 

Comments