a string of characters can be single variable called derived datatype named 'array' which is derived from basic datatypes int, char or float. its declaration syntax is type array_name[size of array];
for eg to store an string of characters declare an array as follows, char name[10]; by this declaration an array of datatype char can used to store 10 characters in the array named name. values can be stored in many ways using scanf, gets etc. simple way is using gets function. simply write the code as follows to get values:- gets(name); refer array for more details.
honey_57
2009-04-04 09:24:07 UTC
the datatype for multiple characters is a character array..
The two ways of handling character strings in C are as follows:
char* character_string;
and
char character_string[ array_length ];
In both cases, the character string has to be terminated with a null character (0 or '\0') as a signal character. Note that this isn't really a separate data type.
There are several built-in string handling functions, such as strlen(), strcpy() and strstr().
C++, being object-oriented, has actual string classes.
Hope that helps.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.