C input

The input has a line of positive integers. You must process all integers in this line.

1
2
3
4
  while(scanf("%d", &x)){
    //do something
    //terminate condition  //this I want to figure how
  }


I tried scanf("%d%c", &x, &c) and terminate it when c != ' '. But then the input has something like
1 2 3 4 5 

which end with a space then next line.
Last edited on
1
2
3
4
int x;
while(1l == scanf("%d", &x)) { 
  /* your code here */  
}

It works, tks!! Mind if I ask what does 1l means?
Topic archived. No new replies allowed.