Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
In C Programming we don’t have Sting data type hence use array of character to
creating string. Suppose we have to accept the name of the person then n
characters are collected together and string or character array is created.
Syntax :
char String_Variable_name [ SIZE ] ;
Examples :
char city[30];
char name[20];
char message[50];
These are some sample declarations of the String.In the first example we have
defined string to store name of city.Maximum Size to store City is 30 which must
be specified inside the Square brackets.
char city[30];
above example ,
Point Explanation
Bound Checking C Does not Support Bound Checking i.e if we store City with size
greater than 30 then C will not give you any error
Maximum Size 30
Some Precautions to be taken while declaring Character
Variable :
1. String / Character Array Variable name should be legal C Identifier.
2. String Variable must have Size specified.
char city[];
Above Statement will cause compile time error.
3. When you are using string for other purpose than accepting and
printing data then you must include following header file in your code -
#include<string.h>
In Short :
To Store "CAT" instead of "CAT@'af" we use NULL Character