Inbuilt Functions

Standard Functions

C++ uses an appropriate abstraction that we call streams for performing the input and output operations in the sequential media like the system screen, the keyboard, or any file as well. Moreover, when we say the term ‘Input’, it refers to feeding some data into any program. Further, we can give input in the form of a file or through the command line. In addition, when we say the term ‘Output’, it refers to displaying some data on the computer screen, printer, or in any given file. This article will help you learn about standard functions in detail here.

standard functions

C++ stdio.h

We can also perform the input and the output operations in C++ with the use of C Standard Input and Output Library i.e. cstdio, also known as stdio.h in the C language. Moreover, this library uses the streams for operating with the physical devices as well.

C++ gets()

The gets() function in C++ basically reads the characters from the ‘stdin’ and it also stores them until a newline character is initiated or the end of the file arises.


This is how the gets() function actually works:




using namespace std;

int main()


char str[100];

cout << "Enter a string: ";


cout << "You entered: " << str;

return 0;


When we will be running the program, the output will be as follows:


Enter a string: Have a good day!

You entered: Have a good day!

C++ puts()

The puts() function in C++ basically writes down a string to the ‘stdout’.


This is how the puts() function actually works:



int main()


char str1[] = "Happy New Year 2021";

char str2[] = "Happy Birthday Dear";


/*  Printed on new line since '/n' is added */


return 0;


When you run the program, the output will be:


Happy New Year 2021

Happy Birthday Dear

Browse more Topics under Inbuilt Functions

The scanf() Functions

The int scanf(const char *format…) function reads the given input from the standard input stream the ‘stdin’ and then scans that input on the basis of the available format.

The printf() Functions

The int printf(const char *format…) function writes the given output to the standard output stream ‘stdout’. After that, it then delivers the output on the basis of the format available.

Moreover, the format can be present in the form of a simple constant string. However, we can specify ‘%s’, ‘%d’, ‘%c’, ‘%f’, etc., for printing or reading the strings, integer, character, or the float respectively.




int main( ) {

char str[100];

int i;

printf( "Enter a value :");

scanf("%s %d", str, &i);

printf( "\nYou entered: %s %d ", str, i);

return 0;


When we will compile and execute the code available above, it will wait for us to input some text. Moreover, then we get the following output:



Enter a value: eight 8

You entered: eight 8

FAQs on Standard Functions

Question 1: What are the input functions?

Answer: We use these functions to allow the transfer of the information between the computer system and the standard input or the output device.

Question 2: What is the standard input and output standard functions?

Answer: The input refers to provide the program with the data to be used within the program. Whereas, the Output refers to display the data on the system’s screen or write the data to a printer or any file.

Question 3: What is the function of puts()?

Answer: The puts(const char *str) function writes down a string to ‘stdout’ up to but not comprising the null character. Moreover, a newline character is added to the output.

Share with friends

Customize your course in 30 seconds

Which class are you in?
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
Ashhar Firdausi
IIT Roorkee
Dr. Nazma Shaik
Gaurav Tiwari
Get Started

Leave a Reply

Notify of

Download the App

Watch lectures, practise questions and take tests on the go.

Customize your course in 30 seconds

Which class are you in?
No thanks.