by Dinesh Thakur Category: C Programming (Pratical)

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.

  1. Declare variables.
  2. Using string functions.
  3. 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);
}

Scan Through fgets

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content