String Length Program in C
Implementation
Now, we shall see the actual implementation of the program −
#include <stdio.h>
int main() {
char s1[] = "TajMahal";
int i = 0;
while(s1[i] != '\0') {
i++;
}
printf("Length of string '%s' is %d", s1, i);
return 0;
}
Output
Output of this program should be −
Length of string 'TajMahal' is 8
string_programs_in_c.htm
Advertisements