What is this for loop??

Can someone explain to me what this for loop is doing?

1
2
for(ifstream fin("integers1.txt"); fin >> left[lpos++] >> right[rpos++]; );
	lpos--; rpos--;


Step by step if you could. Thank you so much!!!
It does
1
2
3
4
5
ifstream fin("integers1.txt");//open a file
if (fin >> left[lpos++] >> right[rpos++]) //try reading things from it
  if (fin >> left[lpos++] >> right[rpos++]) //if succeeded, try reading more
     if (fin >> left[lpos++] >> right[rpos++])
        ... //repeat until failure 

operator >> sort of returns 0 when an error (such as end of file) occurs.
What does the "lpos--" and "rpos-- mean? I know that it decrements it, but why does it do it?
its depending on the rest of the code;
lpos : left position;
rpos : right position;
what's wrong ??
The final fin will have incremented rpos and lpos to now be indices one past the end of right and left respectively. By decrementing them they now index the last integer added to the arrays.
Thank you steve.
Topic archived. No new replies allowed.