Write a C program which prompts the user with the
following options at the command prompt:
1. Enter New Text String
2. Count the Alphabets
3. Count the Words
4. Quit the Program
After running the program will ask user to enter any text
string and perform the operation as given in the options.
Please Give the Appropriate answer.
Answers
menu
home
TUTORIAL
EXAMPLES
search
C Program to Find the Length of a String
In this article, you'll learn to find the length of a string without using strlen() function.
To understand this example, you should have the knowledge of following C programming topics:
C Programming Strings
String Manipulations In C Programming Using Library Functions
C Programming for Loop
You can use standard library function strlen() to find the length of a string but, this program computes the length of a string manually without using strlen() funtion.
Example: Calculate Length of String without Using strlen() Function
#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;
}
Output
Enter a string: Programiz
Length of string: 9