I would like to take an array of integers as an input . Even if some one enter a space or an alpahabet, I want to ignore it.
int i=0;
while(L--){
scanf("%d",&arr[i++]);
}
But if I enter: 4 wtf the arr[0]
gets initialized to 4 and the loop ends. Is there a way I can ignore everything after a space in scanf
and just take the integers.
The input can be of form: 4 abc 3 def 7 ghi.