find the errors

Hi I'm new to programming, but I'm trying to figure out the error in this program segment. please help. When I try to compiler and run it.

char x = 'a', y = 'a';
if (strcmp(x,y) ==0)
exit(0)

here's the errors I get
In function `int main(int, char**)':
invalid conversion from `char' to `const char*'
initializing argument 1 of `int strcmp(const char*, const char*)'
invalid conversion from `char' to `const char*'
initializing argument 2 of `int strcmp(const char*, const char*)'
Last edited on
Exit is a system command. Do not use it. You also forgot the ; after it.
As the error message says, you should character arrays:

1
2
3
  char x[] = "a";
  char y[] = "b";
  if(strcmp(x,y)) 1;
strcmp uses two parameters. Both of them being constant character pointers. You are passing characters to the function. So clearly there's a mismatch.
Topic archived. No new replies allowed.