0
What means char arrays please?
Because I confused that
2 Respuestas
+ 3
Character array means a array of characters.
#define MAXSIZE = 32;
char charArray [MAXSIZE] = '\0';
//in the program somewhere...
charArray = "Mohammed Mowlid";
In good old C language a string (say "Bharat" is actually an array of characters ended with a bill character (NULL or '\0')). In C language all strings are null terminated (just like you use the period or full stop to mark an end to an English sentence).
in C++ you have the string class. as the name suggests it's a class and you can create string objects with that. continuing with the above example, we have say...
string countryName = "Bharat";
here Bharat becomes an object of type string class with length 6.
#include<string>
// somewhere in the program....
string name = "Mohammed Mowlid";
// well that's all you need.
// you need not worry about nulls.
In C++ too you can use the c-style strings, but that's not required as C++ standard library has the string class that does most of what you want to do with strings.