-1
#include<stdio.h>
int main()
{
    int a,b;
    char i;
   do{
        scanf("%d%d",&a,&b);
        printf("%d\n",b-a);
    }while(a!=EOF);
   return 0;
}

In this program when i press ctrl+z(EOF) it doesn't terminate.It print the last value and continue until I close the output console manually.What's the problem here?

Md Soman Khan
  • 25
  • 1
  • 2
  • 5

1 Answers1

0

If you want to kill the program you have to press Control+C instead of Control+Z.

Here, The program iterates without stopping because it couldn't find a!=EOF condition. Because a is a address of memory location and the difference between those addresses never equals to EOF character. Therefore it iterates untill timeout.

Darshana
  • 130
  • 1
  • 8