Taking Appropriate number of test cases from input buffer

I am having problem in solving a part of problem.
In this problem, we are given an input buffer and we have to take appropriate number of test cases of inputs from it.
For example, the input can be 3 4 or 2 4 5 2. Here, we need to take care of both 2 input case and 4 input case.
So, how do we take care of different number of test cases. My language of programming is C/C++.

int test,number,i;
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%d",&number);
}

int test_number;
scanf("%d",&test_number);
while(test_number!=0)
{

test_number–;
}

The correct answer is -
int num;
while(scanf("%d",&num))
{ …
}

@mandeep31 actually it is while(scanf("%d",&num)==1)…as, if no number is taken as input then scanf returns -1…which is considered as true…!!

Note: only 0 is considered as false…rest all the numbers are true…!!

Hope this helps…:slight_smile: