Array getline

Hello, I have a array vard[] and when i try use getline to read txt file
My computer is 123456789
Best computer is 987654321
But my computer is good

int sk = 3;
1
2
3
for(int k = 0; k<sk; k++){
		getline(fd, vard[k]);
      }

I get bad results
My computer is 123456789
Best computer is 987654321
Best computer is 987654321

Why?
Any answers?
You'll need to show more code.
Ok, here's my full reading function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void Read(int & sk, int & men, double & price, string vard[], int INF[5][5]){
	ifstream fd(CD);
	fd >> sk >> men >> price;
	for(int k = 0; k<sk; k++){
		getline(fd, vard[k]);
		cout << vard[k] <<endl;
	}
	for(int i=0; i<sk; i++){
		for(int j=0; j<men; j++){
			fd >> INF[i][j];
		}
	}
	fd.close();
}


here's sk = 3
men = 4
price = 2.5
Last edited on
Hope to get answer, ciz now I don't know whats wrong???
Topic archived. No new replies allowed.