Table of Contents
show
In C programming, array of character are called strings. A string is terminated by null character /0
Example
COMPUTER PROG
C | O | M | P | U | T | E | R | P | R | O | G | \0 |
Here, “COMPUTER PROGl” is a string. When, compiler encounters strings, it appends null character at the end of string.
Declaration of Strings
Strings are of char type
char arr_name[arr_size];
Example
char s[5];
Here, s is name of array
Initialization of Strings
In C, string can be initialized in different number of ways.
char c[]="abcd";
OR,
char c[5]="abcd";
OR,
char c[]={'a','b','c','d','\0'};
OR;
char c[5]={'a','b','c','d','\0'};
String Operations
Strings handling functions are defined under "string.h"
header file
Views: 0