简体   繁体   中英

what is the difference between one length of char*/char[] and char in C?

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM