Find the length of a string with C.
#include <stdio.h>
#include <string.h>
int main()
{
char text[100]; /* Declares a string of size 100 */
int length;
printf("Enter any string: ");
gets(text);
/* Call strlen() function to count length of string */
length = strlen(text);
printf("Length of '%s' = %d", text, length);
return 0;
}
Output
Enter any string : Rezaul
Length of 'Rezaul' = 6
0 Comments