gets() In C Programming

The C gets function is used to scan or read a line of text from a standard input (stdin) device and store it in the String variable. When it reads the newline character, then the C gets function will terminate.

How To Use gets() Function

Some of the important points about gets() are:

  •  gets() is used to take input from the user.
  • gets() is used to take a single input at a time but can be used to input a complete sentence with spaces unlike scanf().

Syntax of GETS in C Programming

The basic syntax behind the Gets in C Programming language is as shown below.

You have to include the #include<stdio.h> header before using this Gets function.


The gets function used to read the complete set of characters from the console. This program will help you to understand this gets function practically.


Top Book Suggestion

The two books on C Programming Language that I Personally Recommend. I really loved reading these books. These books are listed for quality content, easy steps, and affordable price. You can get it from Amazon and Flipkart. 


Check The Price On Amazon:

1. C Programming Beginner’s Guide

2. Head First C: A Brain-Friendly Guide

Check The Price On Flipkart:

1. Introduction to C Programming 

2. Head First C: A Brain-Friendly Guide

Pin It on Pinterest

Share This