Unformatted input/output functions in c language

 Unformatted Input/Output Function -

# Input functions- 

Getchar(), getch(), getche(), gets() etc. 

# Output functions-

Putchar(), putch(), and puts() etc. 


Input Functions -

getchar()- 

Getchar() function will read or display 
 a single character from the standard input.

Example -

#include <stdio.h>
#include <Conio.h>
void main ()
{
char k; 
k =getchar();
getch();

}

getch()-

getch () reads a single character from standard input .the input character is not displayed on the screen. getch()
return when the first char is entered 
and does not wait for enter to be key pressed.

Example  -
#include <stdio.h>
#include <Conio.h>
void main ()
{
char k; 
Printf("enter any character");
Scanf("%x",&k); 
k=getch();
getch();
}

getche()-

getche() is same as getch () except that 
it echoes the input character.

Example -

#include <stdio.h>
#include <Conio.h>
void main ()
{
char k; 
Printf("enter any character");
Scanf("%c",&k) ;
k =getche();
Printf("ASCII number of character
 %c is %d",chili, ch);
getch();
}

gets()-

This function is displayed a set of character or string.
Example -


#include <stdio.h>
#include <Conio.h>
void main ()
{
char str[ 10]; 
gets(str);
getch();
}

Putchar()-

Putchar() will print a single character on standard input. The characters to be 
Printed is passed to putchar () as an arrangement. The character return value of putchar () is the character which was written to the output.
Example -

#include <stdio.h>
#include <Conio.h>
void main ()
{
char k; 
getchar(k);
getch();
}

Putch()-
Putch () is writing a character that is passed as an arrangement to the
 console.

Example -

#include <stdio.h>
#include <Conio.h>
void main ()
{
char k; 
k =getch();
Putch(k);
getch();
}

Puts()-
This function is displayed or read a set of character or string. 

Example -

#include <stdio.h>
#include <Conio.h>
void main ()
{
char ste[20]; 
gets(str);
puts(str);
getch();

}



No comments:

Post a Comment