declaration as follows:
char name[10] = {‘D’, ‘r’, ‘.’, ‘R’, ‘A’, ‘J’, ‘I’, ‘V’ };
We can also write the following:
char name[ ] = {‘D’, ‘r’, ‘.’, ‘R’, ‘A’, ‘J’, ‘I’, ‘V’ };
Please note that during array declaration, if the subscript (array size) is omitted, it is
assumed to be the size of the data with which the array is initialized. This means that the size
declaration is optional in array declaration. Also note that it is the duty of the user to remember
the number of characters stored in the array.
What Are Strings in C?
A string is a special character array which is terminated by a NULL character. This NULL
character is represented by ‘\0’ (ASCII value of NULL is 0).
Strings in C are enclosed in double
quotes.
For example,
“Dr. Rajiv Chopra is a Ph.D. in Computer Science”
Each character is stored in 1 byte. The last character is a NULL character.
Do'stlaringiz bilan baham: |