Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
283 views
in Technique[技术] by (71.8m points)

string - 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 knowstr point to a memory space which stored [a, ], but I want to ask whether there is a difference between str[0] and ch?

question from:https://stackoverflow.com/questions/66047105/what-is-the-difference-between-one-length-of-char-char-and-char-in-c

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...