Array and String
Array and String
float
1 // data[2][4]
2 can be initialized like this also
int data[2][4]={{1,2,3,4},{5,6,7,8}};
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.
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
name[10 D A R S H A N \0
]
Program
Outpu
1 #include <stdio.h> t
2 #include <string.h> //header file for string functions Enter string: CE
3 void main() Darshan
4 { 10
5 char s1[10];
6 printf("Enter string:");
7 gets(s1);
8 printf("%d",strlen(s1)); // returns length of s1 in in
9 teger
}
Thank you