String

                                                                    String

String is a set(array) of character which is terminated by '\0'(null character). When compiler assigns string to character array then it automatically supplies null character ('\0') at the end of string. Thus, size of string = original length of string + 1.

Declaration of string:- 
 

char <string name>[roof character];

Example:- 

char str[15];

Initialization of strings:- 
 
char str[15]="ankit";
//or
char str[15]={'a','n','k','i','t','\0'};//you must put '\o'(null)in this method
                  
                  //printing

printf("%s",str);// string printing
printf("%c",str[i]);// character printing

                 //scanning

scanf("%s",&str);// string scanning
scanf("%c",&str[i]);// character scanning


Comments

Popular posts from this blog