I have a function (in C) that receives input from a user (using scanf) saves it in an unsigned int and returns input to other functions that process it:
unsigned int input(void) { unsigned int uin; scanf("%u", &uin); return val; }
I was wondering that since I have to clear stdin, I would like to use a while loop using getc, vis-a-vis:
while (getc != '\n') { ... }
But I'm not sure how:
A) Perform operations inside getc, as in how I should process the checks and concatenate the value, to each character received, or regardless of whether I should getc and then concatenate from there, completely removing scanf.
B) This is even the most correct way to do this.
Can any person give me some tips and pointers :)
Thanks.
source share