fflush:
It flushes the specified stream.
Syntax:
fflush(streamname);
Eg: fflush(stdin);
flushall:
It flushes all open streams.
Syntax:
flushall();
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
char ch;
clrscr();
printf("Enter any Integer :");
scanf("%d", &n);
printf("Enter any Character :");
fflush(stdin); // (or) flushall();
scanf("%c", &ch);
printf("\nGiven Integer is :%d", n);
printf("\nGiven Character is :%c", ch);
getch();
}
Output:
Enter any Integer :20
Enter any Character :A
Given Integer is :20
Given Character is :A
Next Topic : string function
Previous Topic : Skipping Problem
No comments:
Post a Comment