I have this block of code and it's supposed to trigger a message when the user punches in Ctrl+D and enters it, but no message appears. Can someone explain to me why this is so?
#include <stdio.h>
int main()
{
int i=0;
int result = scanf( "%d", &i );
if( result == EOF )
{
printf( "End of file detected\n" );
}
}
It just doesn't seem to want to print my message when I punch in Ctrl+D on the keyboard and entering the result ^D
.
Ctrl-D is the Linux shortcut for EOF. On Windows press F6 or Ctrl-Z, Enter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With