With which function can you find the length of a string? Write a program in C to find the length of a string.
Answers
Answered by
1
#include <stdio.h>
int main()
{
char s[1000];
int i;
printf("Enter a string: ");
scanf("%s", s);
for(i = 0; s[i] != '\0'; ++i);
printf("Length of string: %d", i);
return 0;
}
Answered by
1
Answer:
strlen()
Program:
#include<iostream>
#include<cstring> //To use strlen() function
using namespace std;
{
char str[]= "Welcome";
int n;
n = strlen(str);
cout << n;
return 0;
}
Output will be obtained:
7.
Explanation:
I hope it will useful for U.
Thank U
Similar questions
Geography,
7 months ago
English,
7 months ago
Social Sciences,
7 months ago
Math,
1 year ago
Social Sciences,
1 year ago