Strings
String:
A string is a one-dimensional array of characters terminated by a null ('\0').
Declaration of string:
We can declare a string in C by making an array of char data-type.
Syntax:
char array-name[size];
Example:
char name[10];
The above example will make 10 characters long string which is essentially an array of 10 characters.
Null character:
For string, each character in the array occupies one byte of memory, and the last character must always be null ('\0').
the termination character ('\0') is important in a string to identify where the string ends.
Example:
char name[10] = {'I', 'R', 'O', 'N', 'M', 'A', 'N', '\0'};
Drafted on 🌏 by,
Jal
☮
peace
Comments
Post a Comment