04-24-2011, 04:52 PM
Dear student!
Null character is special character that is added to array just to indicate end of string. If a string has n characters then it requires an n+1 element array (at least) to store it.
A string variable s1 could be declared as follows:
char s1[10];
The string variable s1 could hold strings of length up to nine characters since space is needed for the final null character.
The single-character string "a" is stored in two consecutive bytes holding the character `a' and the null character. It would declared as follow:
char s1[2];
Null character is special character that is added to array just to indicate end of string. If a string has n characters then it requires an n+1 element array (at least) to store it.
A string variable s1 could be declared as follows:
char s1[10];
The string variable s1 could hold strings of length up to nine characters since space is needed for the final null character.
The single-character string "a" is stored in two consecutive bytes holding the character `a' and the null character. It would declared as follow:
char s1[2];
