xxxxxxxxxx
#include <string.h>
int main() {
char str[] = "Hello World";
int length = strlen(str);
printf("Length of string: %d\n", length);
return 0;
}
xxxxxxxxxx
#include<stdio.h>
#include<string.h>
void main(){
int lenght;
char name[100];
printf("Enter a string : ");
scanf("%s",&name);
lenght = strlen(name);
printf("lenght of the string = %d",lenght);
}
xxxxxxxxxx
#include <stdio.h>
int main()
{
char s[] = "Dhiraj";
int i=0;
while(s[i] != '\0')
{
i++;
}
printf("length of string is %d", i);
return 0;
}
xxxxxxxxxx
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "Hello, World!";
int length = strlen(str);
printf("Length of the C string: %d\n", length);
return 0;
}
xxxxxxxxxx
/**
* A PROGRAM THAT RETURNS THE LENGTH OF A STRING FROM THE USER
*/
#include <stdio.h>
/**
* _strlen - takes a string and returns its length
* @i: counter variable
* @*s: the string entered by the user from the terminal
* Return: Length of the string = i
*/
int _strlen(char *s)
{
int i;
for(i = 0; s[i];)
i++;
return(i);
}
/**
* main - start of this program
* @str: string entered by user
* Return: 0 when runs successfully
*/
int main()
{
char str[100];
printf("Enter your string\n");
scanf("%s",str);
printf("%s is %i characters\n", str, _strlen(str));
return 0;
}
xxxxxxxxxx
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "Hello, World!";
int length = strlen(str);
printf("Length of the string: %d\n", length);
return 0;
}