• Input means to provide the program with some data to be used in the program
  • Output means to display data on screen or write the data to a printer or a file.
  • C programming language provides many built-in functions to read any given input and to display data on screen when there is a need to output the result.
  • In this tutorial, we will learn about such functions, which can be used in our program to take input from user and to output the result on screen.
  • All these built-in functions are present in C header file "#include<stdio.h>"
  • To use the built in functions we have to specify header files at head in which a particular function is defined(written) while discussing about it.

Strings I/O
gets() & puts()

gets() Function:

  • When you have to take input of more than One character then this function is Used.
  • This Function is used to take input of Bunch of character
    which is called as string.

Syntax:

gets(variable_name);

Example:

#include<stdio.h>            //header file

void main()
{
char b[10];        //this  a string declaration,which will see further.
gets(b);
}


puts() Function:

  • When you have to print of more than One character then this function is Used.
  • This Function is used to print of Bunch of character
    which is called as string.

Syntax:

puts(variable_name);

Example:

#include<stdio.h>            //header file

void main()
{
char b[10];
gets(b);         //we took string as input.
puts(b);        //printing the string.
}

Output

Hello world


Example2:

#include<stdio.h>

void main()
{
    char s[10];

    printf("Enter any string:");
    gets(s);

    puts(s);

}

Output:
Enter any string: Programmers are great
Programmers are great.



Further Concepts: