0

enter image description here

( I hit enter)

#include<stdio.h>
#include<stdlib.h>
int main(){
    int target,result;
    while(1){
        printf("Please input your target: ");
        scanf(" %d",&target);
        if(feof(stdin)){
            break;
        }
        printf("test\n");       
    }
}

if I chnage the code to: (delete the space)

#include<stdio.h>
#include<stdlib.h>
int main(){
    int target,result;
    while(1){
        printf("Please input your target: ");
        scanf("%d",&target);//no space
        if(feof(stdin)){
            break;
        }
        printf("test\n");       
    }
}

it worked

enter image description here

Barmar
  • 741,623
  • 53
  • 500
  • 612

0 Answers0