Answers for "how to check the length of a scanned string c"

C
0

how to find length of string in c

// include all the libraries used in the program.
#include <stdio.h>
#include <string.h>

// Calculate Length of String Using strlen() Function
int main() 
{ 
    char a[100]; int length;
	printf("Enter a string to calculate its lengthn"); gets(a);
	length = strlen(a);
	printf("Length of the string = %dn", length);
	return 0; 
}

// Calculate Length of String without Using strlen() Function
int main() 
{
    char s[] = "Programming is fun";
    int i;

    for (i = 0; s[i] != ''; ++i);
    
    printf("Length of the string: %d", i);
    return 0;
}
Posted by: Guest on January-05-2021

Code answers related to "how to check the length of a scanned string c"

Code answers related to "C"

Browse Popular Code Answers by Language