I learnt that C doesn't have string data type. In order to store a string value we have to define an array variable of char data type.
I just need a clarification. If I want to store a string up to 20 characters, do I have to define the variable as
I ask this because I read somewhere in the book, it says that a string must also include the null character, '\0'.
I tried defining a variable to store the grade value as the following:
Then I use the scanf("%s",grade) to read the value. When I keyed in the grade as B+ and later print it back as follows:
printf("The grade you have entered is [%s].", grade)
It appeared as:
The grade you have entered is [B+].
It seems that it accepted the entry as two characters. Does it mean the null character is not counted in the array size?