Code: Select all
int main()
{
printf("Hello world (input a number): ");
int a = 7;
scanf("%d",&a);
printf("%d",a);
return 0;
}
However, no matter what number I enter it just reads 1024 bytes from stdin again. Is this expected behaviour???
Moreover, and more worrying, when the scanf is excluded, no write syscall occurs. Ie a program that only printfs has no effect. BUT a program that prints to stderr (fprintf(stderr,"Hello")) makes the syscall.
Afaik, the only difference between stdio and stderr wrt an application is that the one is buffered and the other not. But surely both must get written at some time. Am I missing something?