Strings are one dimensional character array. Strings always terminate by null character “\0” having the ASCII value zero as well. Strings data types also follows contagious memory allocation. Basic Syntax of String Declaration is Char String_Name[String Size]; Operations include stelen, strcpy, strcmp, strcat etc.
Declaration of Strings
In method 1 we also set String size along with string name and char keyword for declaration of string.
In method 2 we do not set String Size along with string Name and char keyword.
It will automatically take the size of the of string.
Method 1
char String_Name [String_Size];
Method 2
char String_Name [];
Initialization of Strings
Method 1 : Type 1
char a [11] = "prepinsta";
Method 1 : Type 2
char a [11] = {'p','r','e','p','i','n','s','t','a','\0'};
Method 2 : Type 1
char a [] = "prepinsta";
Method 2 : Type 2
char a [] = {'p','r','e','p','i','n','s','t','a','\0'};
Login/Signup to comment