Course Content
Detailed Content of Programming in C
0/1
Introduction
0/1
Structure of C program
0/1
Answers of ‘C’ Pointers Programs
0/1
About Lesson

Program to Find the Length of a String.

#include <stdio.h>
#include <string.h>

// Function to find the length of a string
int findStringLength(char str[]) {
return strlen(str);
}

int main() {
char inputString[100];

// Taking input for the string
printf(“Enter a string: “);
scanf(“%s”, inputString);

// Calling the function to find the length and printing the result
int length = findStringLength(inputString);
printf(“Length of the string “%s”: %dn”, inputString, length);

return 0;
}