0
char str[] = "a";
char ch = 'a';

speaking of the difference between the two, we all knowstr point to a memory space which stored [a, \0], but I want to ask whether there is a difference between str[0] and ch?

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
ijpq
  • 17
  • 5

1 Answers1

3

but I want to ask whether there is a difference between str[0] and ch?

No.

str[0] and ch, both are of type char, and hold the value 'a'. From this aspect (type and value), there is no difference.

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261