how to find length of string in c
// include all the libraries used in the program.
#include <stdio.h>
#include <string.h>
// Calculate Length of String Using strlen() Function
int main()
{
char a[100]; int length;
printf("Enter a string to calculate its length\n"); gets(a);
length = strlen(a);
printf("Length of the string = %d\n", length);
return 0;
}
// Calculate Length of String without Using strlen() Function
int main()
{
char s[] = "Programming is fun";
int i;
for (i = 0; s[i] != '\0'; ++i);
printf("Length of the string: %d", i);
return 0;
}int main() { char a[100]; int length;
printf("Enter a string to calculate its length\n"); gets(a);
length = strlen(a);
printf("Length of the string = %d\n", length);
return 0; }
Also in C:
- azure storage emulator config
- c printf uint32_t
- how to input a string into a char array cpp
- Declaring Variables in C
- arduino internal pull up resistor
- oop244
- change no_turbo
- create point cloud from rgbd image in open3d v0.10
- how to draw a graph or histogram in c language
- c read a whole string from a file
- windows forms picturebox has image
- division recursiva
- fcfs disk scheduling in c
- XAudio2 C
- confirm sweet alert
- how to add user to role postgresql
- read from command line c
- how to make services in linux
- c input output
- docker-compose file break line
- selection sort
- pass the pointer in C
- how to use malloc in c
- fibonacci sequence single recursive call