Answers for "string length in c without using strlen and string header"

C
1

string length in c without using strlen and string header

#include <stdio.h>
// function for string length
int string_length(char str[])
{
    int i;
    // you can use while loop
    for( i = 0; str[i] != '\0';i++);
    return i;
}
int main()
{
    // declaring character array
    char your_name[20]; // you can change the maximum size of string
    printf("Type you full Name : ");
    // taking input from user
    gets(your_name);
    // using string length function
    int length = string_length(your_name);
    // printing string length
    printf("\nLength of your name (%s) is : %d \n\n",your_name,length);

}
Posted by: Guest on June-24-2021

Code answers related to "string length in c without using strlen and string header"

Code answers related to "C"

Browse Popular Code Answers by Language