Difference between char *str = “…” and char str[N] = “…”? [duplicate]
问题 Possible Duplicate: What is the difference between char s[] and char *s in C? Question about pointers and strings in C I'm reading about the strings in C and I'm confused. I can "declare" strings in two ways: char *str = "This is string"; char str2[20] = "This is string"; What is the difference between the two declarations? When would char str2[20] be preferred over char *str ? 回答1: char *str = "This is string"; Puts the string in the constant data section (also known as .rdata) of the