+ 1

What is difference between string str="string"; and char str[50]={'s','t','r','i','n','g'}; ?

12th Aug 2019, 8:05 AM
Batul Makada
Batul Makada - avatar
2 Answers
+ 3
Atleast one difference is that you can change characters of an array, but you can't change strings after creation.
12th Aug 2019, 8:30 AM
Seb TheS
Seb TheS - avatar
+ 1
Char array is just an array which contains different characters. Char is a primitive data type. String is 0 or more characters. For example in java string is a class.
12th Aug 2019, 8:15 AM
Lennie
Lennie - avatar