Write the function LENGTH which returns the length of a string of characters CH as result.
Difficulty level
![](images/star1.png)
Video recording
This exercise is mostly suitable for students
#include <stdio.h>
#include <conio.h>
int length(char str[])
{
int i = 0;
while (str[i])
i++;
return i;
}
void main()
{
char str[100];
printf("Enter a string: ");
gets(str);
printf("length=%d\n", length(str));
getch();
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
![](images/star3.png)