using strcmp for two dimensional arrays

hi guys, how can i use strcmp function to compare an amount of char array like a[0][0] with a char like "*"?
i tried to use it like this but it shows error:
a array will be taken from the user
1
2
3
4
5
6
   char a[10][10];

  if (strcmp(a[0][0], "*") == 0)
  {
     cout << "yes";
  }
Last edited on
"*" is not a char. it is a string. '*' is a char.
strcmp does not compare chars. It compares c-strings.
If you need to compare specific char on specific position, do it directly:
if( a[0][0] == '*')

If you need to compare strings, then compare strings (c-string is a character array, you have array of char arrays aka array of c-strings)
if( strcmp(a[0], "*") == 0 )
thanks, i was completely confused
Topic archived. No new replies allowed.