Write a program that prompts the user to input a string and display the length of string.

Source Code

#include <stdio.h>

int main()
    char str[80];
    int l;

    printf("Enter a string: ");

    /* Find the length of the string */
    for (l = 0; str[l] != '\0'; l++);

    /* Display the length of string */
    printf("The length of string is: %d", l);

    return 0;


Enter a string: C programming
The length of string is: 13