Use strlen to find out the length of a string in C

#include <stdio.h>
 #include <string.h>
 
 int main()
 {
    char text [80];
    int length;
 
    printf("Enter a string : ");
    scanf("%s",text);
    length=strlen(text);
    printf("nThe length of the string is : %d.n",length);
    return 0;
 }

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.