- Temporary storage area is called as buffer.
- In implementation when we are passing more than required number of input values then automatically remaining values are stored into standard input buffer and these values automatically will pass to next input functionality.
int main()
{
int value1, value2;
clrscr();
printf ("\n Enter Value-1: ");
scanf("%d", &value1);
printf ("\n Enter Value-2");scanf("%d", &value2);
printf("\n Sum of Value1+Value2 = %d", value1+value2);
getch();
return 0;
}
Output:
Enter Value-1: 10 20
Enter Value-2:
Sum of Value1+Value2 = 30
flushall(); //fflush(stdin);
scanf("%d", &value2);
printf("\n Sum of Value1+Value2 = %d", value1+value2);
getch();
return 0;
- In implementation when we require to remove temporary data form standard input buffer then go for flushall() or fflush().
- flushall() is predefined function which is declared in <stdio.h>, by using this function we can remove the data from standard input buffer.
- When we are working with flushall() it doesn't return any value and doesn't take any parameter.
void flushall(void);
fflush():-
- fflush() is predefined function declared in <stdio.h>, by using this function we can clear standard input buffer data.
- fflush() require one argument of type FILE* and doesn't returns any value.
void fflush(FILE*stream)
Example:
#include<stdio.h>
#include<conio.h>
int main()
{
int value1, value2;
clrscr();
printf ("\n Enter Value-1: ");
scanf("%d", &value1);
printf ("\n Enter Value-2");flushall(); //fflush(stdin);
scanf("%d", &value2);
printf("\n Sum of Value1+Value2 = %d", value1+value2);
getch();
return 0;
}
Output:
Enter Value-1: 10 20 30 //here only 10 will be accepted by compiler 20 and 30 will be
Enter Value-2: 30 // cleared by flushall()
Sum of Value1+Value2 = 40
Thanks For Post which have lot of knowledge and informataion thanks.... GOM Mix Pro Crack
ReplyDeletemp3DirectCut Crack
Rubyinstaller Crack
Yandex Browser Crack