0

Hello everyone. Got a bit of a weird problem here. I cant seem to figure out a way to read a file with a format like this...

hello what 100 200

its a string string integer integer

i need to put each of those values in separate arrays.
eg:
array1[0] = hello;
array2[0] = what;
array3[0] = 100;
array4[0] = 200;

I tried this just as a test to what it will print out but as expected its just flat out reading the file. I am not getting any ideas to differentiate between variables and put them in separate arrays.

ifstream MyData("somefile.txt");
		string data;
		string DataArray[500];
		int i=0;
			while(MyData>>data)
			     {
				cout<<data;
				 DataArray[i] = data;
				 i++;					
			     }
			for(int j=0;j<i;j++)
			     {
				cout<<DataArray[j]<<endl;
			     }

Any suggestions would be very much appreciated. Thanks .

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by UberJoker
0

umm....i didnt quite understand that...what i am saying is how to read them individually at all in the first place

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.