2

I am using Clion for C programming,I am running a simple program that should terminate on EOF. However, using ctrl+D doesn't terminate the program.

 int main() {
   int c;
   c = getchar();
   printf("c is %c",c);
   while(c != EOF){
       putchar(c);
       c = getchar();
   }
   printf("exiting now");
   return 0;
}

I do see from output that it stops printing the characters i.e. came out of while loop. But the program seems to be running and the print statement

printf("exiting now");

doesn't get executed.

enter image description here

I have followed sending EOF to stdin in Clion IDE but that doesn't solve it.

This seems to be different from

https://youtrack.jetbrains.com/issue/CPP-5704

Does any one knows how to fix this?

varkashy
  • 374
  • 4
  • 18

0 Answers0