Skip to content

Input Functions in C Programming Language

by yashan on July 21st, 2011

Input functions are the functions through which data is entered into the computer. These functions can feed the data from standard input device like keyboard to the computer. All types of data can be entered into the computer through these input functions.

Input Functions in C programming language are -

  1. getchar( ) – This function is used to input a single character from the keyboard. This function can only store character type data and no other data type can be stored through this function. This function will echo the character on the screen while inputting. This is buffered function.The general syntax is as-
    where v is the vairable of character type. for ex -
    char mn;
  2. getch( ) – This function is similar to the getchar( ) function. But this function does not echo the character on the screen. It stores the character into the computer’s memory . The general syntax is as-
  3. gets( ) – This function in C programming language can input a a complete character string from the keyboard to the computer’s memory. This function can include blanks and special characters in the string. It’s syntax is-
    char nm[80];
  4. scanf( ) – Scanf( ) function can input every type of data. Integer type, floating point, double precision and character data can be inputted through this function. To input data through this function different codes known as control codes or format codes are used to input data of different types. These codes are -

%d – Integer data
%f – float data
%lf – long float or double precision type data
%ld – long interger
%c – for single charater
%s – for string of characters
%u – unsigned integer

General syntax of scanf function is -

scanf("control strings",&v1,&v2,&v3,...&vn);

for ex-
char nm[15];
int a;
float b;
scanf("%s %d %f",nm,&a,&b);

Note that to read the string we don't need to use ' & ' (ampersand sign).
 Whereas it is necessary to use this sign will all other variables of
other data types

From → C Tutorials

One Comment
  1. Nishant permalink

    is there any function in c that wud stop the function being performed as we press any key.???

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS