+ 1
Why does C++ need char type if there are already integer?
2 Respuestas
+ 7
char and int differs in size and data range, char is an 8bit data while int (commonly, depending on system architecture and compiler used) is 32bit. Apart from that, an int can't be printed as character without a proper format.
Hth, cmiiw
+ 3
They are completely different.
By default there's no string type in c++ but there is libraries for it.
You can make a string by using char arrays.
char arr[] = "array";
which is equivalent to
char arr[5] = {"a", "r", "r", "a", "y", "\0"};
The escaped 0 means that the array is a string and you can output it without a need to loop it
cout << arr;