fstream problems

I am trying to read few numbers from text file.

struct xy {
int x,y;
};

xy sod1[1],sod2[1]

ifstream failas;
failas.open("sodininkai.txt");
failas >> sod1[0].x >> sod1[0].y >> sod1[1].x >> sod1[1].y;

If I read first 4 numbers like this, it works great.
But when I add 4 more :

failas >> sod2[0].x >> sod2[0].y >> sod2[1].x >> sod2[1].y;

I get something pretty random. Even sod1 values changes? How can this be explained?
array[1] declares an array of length 1. That is, it has just one element: 0.
sod[1] actually has the same address as sod2[0]. sod2[1] is completely invalid.

So there.
Last edited on
Topic archived. No new replies allowed.