#include <stdio.h>
#include <stdlib.h>
int main()
{
char buf[1024];
int a,b;
int i;
setbuf(stdin, buf);
scanf("%d %d", &a, &b);
for(i=0; buf[i]!='\n'; i++){
putchar(buf[i]);
}
putchar('\n');
return 0;
}
When I input the values 1 2
, I used setbuf
to find out if the buffer was really cleared after reading the values.
When I printed out the buf
, however, the value I entered remained the same in buf
. That is, the output was 1 2
Why is this happening?
I would really appreciate if you could answer.