how can i break from my while statement when i want to scanf numbers like 1 2 3 4 5 and then hit Enter and goes on with my code ... here is what i have done but nothing works
while(1){
    res=scanf("%d",&x);
        arr[i++]=x;
        counter++;
            if ( res == 0 ){
                printf("EOF\n");
                break;
            }
            if ( res != 1)
            {
                printf("Nespravny vstup.\n");
                return 1;
            }
            if ( counter > 100)
            {
                printf("Nespravny vstup.\n");
                return 1;
            }
    }
printf("Counter:%d\n", counter);
				
                        
According to the
manpage of scanf:In your case,
scanfwill return 0 only in case of an early matching failure.