0
When we use the char datatype instead of string?
Why could be better choice a char than a string with only one character?
5 Respuestas
+ 7
I recommend to use char when you want to store single letters only. Since you do not want to accidentally add in more letters into a variable.
Secondly, char will make the system go faster compared to string if your system is consuming hundreds of megabytes per second.
+ 5
Size of char is 1 byte whereas string is 4 bytes. Use string when you need to store large data where you don't know what will be the input data length. Use char when you know length of data and this will more faster than string, use less memory
+ 2
It takes less memory to do 'a' as a character rather than "a" as a string.
0
and when you use only a char? for me it seems very limited.
0
Thanks for explanations!