Question regarding string array

Pages: 12
closed account (Dy7SLyTq)
getline gets a line from a file and stores it in a string. istringstream is a lit bit more complicatd. maybe someone else can, but i cant very well. i just know how to use it. int argc, char *argv[] are command line arguments. they arent needed in the program and can be taken out
okay @DTScode , appreciate your help anyhow.
closed account (Dy7SLyTq)
how about this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
	ifstream file("whatever.txt");
	string names[5];
	int numbers[5][8], i = 0;

	while(i++ < 5)
	{
		cin>> names[i];

		for(int j = 0; j < 8; j++)
			cin>> numbers[i][j];
	}
}
umm noo i compiled it and ran it. if i cout << numbers[i][j] i get the first 8 numbers and then i get weird numbers lol (-9.8657..) for the others. and if i output names[i]
i get only the first...pretty weird.
closed account (Dy7SLyTq)
huh. i thought it would work but its been a while since i tried that without string streams
wait did you want me to intialize i to 0 ?
yeah i see it never mind, but still not working
Last edited on
Topic archived. No new replies allowed.
Pages: 12