Input & Output function in C

 

input output function in C

 

getchar()

getch()

getche()

gets()

putchar()

puts()

scanf(“control strings”, arg1, arg2, . . . argn),

           

printf(“control strings”, arg1, arg2, . . . argn) ;

 

Function

Format

Description

atof() [numvar = ]atof(string); Converts a floating-point value found in string into a floating-point number, which can be stored in a variable, numvar, or used immediately. Requires the STDLIB.H header file to be included.
atoi() [numvar = atoi](string); Converts an integer value found in string into an integer, which can be stored in a variable, numvar, or used immediately. Requires the STDLIB.H header file to be included.
fflush(stdin) fflush(stdin); Removes characters from the input stream (keyboard).
fpurge(stdin) fpurge(stdin); Removes characters from the input stream (keyboard). This function must be used in Unix rather than fflush(stdin).
getchar() [ch = ]getchar(); Reads a single character from the keyboard. The character is displayed and, optionally, stored in the char variable ch.
gets() gets(string); Reads a string of text from the keyboard (terminated by the Enter key). The text is stored in the variablestring.
printf() printf(“format”[,var[,var...]]); Displays formatted text according to the formatstring. Optional values or variables, var, can be specified to match placeholders or conversion characters in the format string.
putchar() putchar(ch); Displays the character ch on the screen, where ch is a single character (or escape code) in single quotes or the name of a char variable.
puts() puts(string); Displays the text string on the screen, wherestring is a literal string of text (enclosed in double quotes) or the name of a string variable.
scanf() scanf(“format”,&var); Reads information from the keyboard according to the conversion character in the format string. The information is then stored in the variable var, which must match the type of conversion character that’s used (int, float, or char, for example).

 

 

 

Format Specifier
Type of Argument

Input

%c

Character

Reads a single character

%d or %i

Integer

Reads a decimal integer

%e or %E or %f or %g or %G

Floating point

Reads a floating point value

%hd or %hi

Short integer

Reads decimal short integer

%hu

Short integer

Reads decimal unsigned short integer

%ld or %li

Long integer

Reads decimal long integer

%le or %lf or %lg

Double

Reads signed double

%Le or %Lf or %Lg

Long double

Reads signed long double

%lo

Long integer

Reads an octal long integer

%lu

Long integer

Reads decimal unsigned long integer

%lx

Long integer

Reads hexadecimal long integer

%o

Octal integer

Reads an unsigned octal integer

%s

Sequence of characters

Reads a string

%u

Integer

Reads an unsigned decimal integer

%x or %X

Hexadecimal integer

Reads a unsigned hexadecimal integer

 

ESCAPE SEQUENCES (BACKSLASH CHARACTER CONSTANTS)

 

ASCII Value

Escape Sequences

Meaning

000

\0

Null

007

\a

Audible alter (bell)

008

\b

Backspace

009

\t

Horizontal tab

010

\n

New line

011

\v

Vertical tab

012

\f

Form feed

013

\r

Carriage return

034

\”

Double quote

039

\’

Single quote

063

\?

Question mark

092

\\

Backslash

 

 

 

 

 

 

Registration


A password will be e-mailed to you.

Feedback Form

Name (required)

Email (required)

Feedback