r/C_Programming • • May 29 '26

Question HELP!!!!

   while(1){
        if(scanf(" %d",&input_choice)==1){
            break;
        };
        
        while(1){
            if(getchar()=='\n'){
                break;
            }
        }
    };
Guys what am i doing wrong can you please tell me .
 i am sorry if i am asking very basic thing . i read some documentation online but couldn't figure out what is going wrong 
0 Upvotes

19 comments sorted by

View all comments

Show parent comment

1

u/Level-Pollution4993 May 29 '26 edited May 29 '26

I added the output at the end of my comment, I hope you can read it. Yes it 'worked'. There are issues but they don't matter rn. That is the simplest solution.

Let me add it again:

Enter an integer: abc
Enter an integer: fv
Enter an integer: 23
The value you entered is: 23

2

u/UsualLonely4585 May 30 '26

Its working thanks man for giving it your precious time