Header Ads Widget

string in c.

 What is string :-

        In C programing a string is define as a sequence of character terminated by a null character written  as ' \0 '.

Example:-

            "Sadab"  ,  "Rajnish1"  ,  "Piyush Tripathi"

In C language string are represented and store of character array where each element of the character array store a single character of the string (In sequence).

Thus a character array can be declare to store some string as follows : -

                     


For example 
                     The declaration  of a character array 'name' which can store the name of some person maximum up to fifteen(15) character long as follow -
    



Initilization of character array 

                                               The element of a character  array  can be initialized  in following two most common ways.
  
(i)  char name[ 6 ] = {'R' ,  'a'  ,  'h' ,  'u'  ,  'l'   '\0' }

(ii)  char name[  ]  =  "Rahul" ;

Note :-   In second here the string  "Rahul"  contains five character , so  the  compiler automatically allocated 6  memory location (one extra for storing null character).





Recommended Post:

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-












 

Post a Comment

0 Comments