C Managing Input ⁄ Output Operations

Single character input output

The putchar function which in analogus to getchar function can be used for writing characters one at a time to the output terminal.
The general form is
putchar (variable name);

Where variable is a valid C type variable that has already been declared
Ex:- Putchar ( );

Displays the value stored in variable C to the standard screen.
Program shows the use of getchar function in an interactive environment.

Sample program (putchar)

#include 'stdio.h'     // Inserts stdio.h header file into Pgm
void main( )           // Beginning of main function.
{ 
	char in;           // character declaration of variable in.
	printf (”enter one character”); //message to user
	in=getchar( );     // assign keyboard input value to in
	putchar (in);      // out put ‘in’ value to standard screen.
} 

The gets function relieves the string from standard input device while put S outputs the string to the standard output device.
A strong is an array or set of characters.
The puts function displays the contents stored in its parameter on the standard screen.
The standard form of the gets function is
	gets (str)

Here str is a string variable.
The standard form for the puts character is
	puts (str) 
Where str is a string variable.
# include 'stdio.h' 
Void main ( ) 
{ 	char s [80];
	printf (“Type a string less than 80 	characters:”); 
	gets (s); 
	printf (“The string types is:”); 
	puts(s); 
} 


Make Comments..!!


Oops!! No posts from user.

Download Android App