0

string and char

What is the difference in using string and char data type

23rd Oct 2019, 2:00 PM
ugoswami11
ugoswami11 - avatar
3 ответов
+ 3
Char: 1. A char holds a single character. 2. Char is a primitive type. 3. Elements in character array are stored contiguously in increasing in memory location. Example: char[ ] a = {'a', 'p', 'p', 'l', 'e'}; String: 1. String holds lots of characters. 2. String is a reference type. 3. Strings can be stored in any manner in the memory. Example: string a = "apple"; Hope it helps 😊 And yeah sorry for grammatical mistake.
23rd Oct 2019, 4:02 PM
Raju Ram Sau
Raju Ram Sau - avatar
0
I think this is explained in the course :) have you done it?
23rd Oct 2019, 2:04 PM
Brave Tea
Brave Tea - avatar
0
in short: string is any combination of chars, but it is a string, which means it is treated as such. 1 + 1 #output 2 but “1 + 1” #output 1 + 1 chars are always single characters and never a combination
23rd Oct 2019, 2:06 PM
Brave Tea
Brave Tea - avatar