You could use the vector class which can hold strings as elements, but you might find it to be too complicated. I suggest reading about the vector class:
#include<vector>
#include<cstdlib>
#include<iostream>
#include<fstream>
usingnamespace std;
int main()
{
int i,j=0;
string holder;
ifstream infile;
infile.open("test.txt");
vector<string>data(9,"0"); /*Declares a vector called data that hold 9 elements
of type string, and initializes each string to 0.*/
for(i=0;i<12;i++)
{
infile>>holder;
if(i%4!=0) //If i/4 has a remainder that is not equal to zero...
{
data[j]=holder;
j++;
}
}
for(i=0;i<9;i++)
cout<<data[i]<<" ";
cout<<endl<<endl;
system("pause");
return 0;
}
My text file looked like this:
1 x1 y1 z1
2 x2 y2 z2
3 x3 y3 z3
EDIT: If you don't want to use the vector class, you can just replace line 1 with #include<string> and line 14 with string*data=new string [9];. It achieves the same effect.