I have the following code:
#include <stdio.h>
int main()
{
char c = 0;
fclose(stdin);
stdin = fopen("newin", "r");
if(stdin != NULLL)
{
scanf("%c", &c);
printf("%d", c);
}
else
printf("Error");
}
I want my program to wait for a change in the stdin file. I created it blank, but it returns 0.
If a put like a 'a' char in it it prints 97 like it should.
How can I make the scanf wait for a change in the file, like it was waiting for me to write in the terminal window?