This is C program here user will find out the length of line (string) for this user declare the variables that contain value for it and string functions for string execution. Declaring a variable with array parameter user ask to enter the line as required in quoted area. After that user put the method about string functions along with it display the result as output as result.
Problem Statement:
This is C program that ask user to scan through fgets.
- Declare variables.
- Using string functions.
- Display result on the screen as output.
Here is C source code to scan through fgets. The output of this program shown below.
#include <string.h>
#include <stdio.h>
char line[100]; /* Line we are looking at */
int main()
{
printf("Enter a line: ");
fgets(line, sizeof(line), stdin);
printf("The length of the line is: %d\n", strlen(line));
return (0);
}