1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
cout<<"Please select number between 1 and 12"<<endl;
cin>>number;
string str[7][12]; //[col][row]
ifstream myfile("TextFile1.txt");
int a = 0;
int b = 0;
if(!myfile) //Always test the file opens
{
cout<<"Error opening output file"<<endl;
system("pause");
}
while(!myfile.eof())
{
if (number==1)
{
getline(myfile,str[0][0],' ');
cout<<"value one is:"<<str[0][0]<<endl;
a=0;
++b;
getline(myfile,str[1][0],' ');
cout<<"value two is:"<<str[1][0]<<endl;
getline(myfile,str[2][0], ' ');
cout<<"value three is:"<<str[2][0]<<endl;
getline(myfile,str[3][0], ' ');
cout<<"value four is:"<<str[3][0]<<endl;
getline(myfile,str[4][0], ' ');
cout<<"value five is:"<<str[4][0]<<endl;
getline(myfile,str[5][0], ' ');
cout<<"value six is:"<<str[5][0]<<endl;
getline(myfile,str[6][0], ' ');
cout<<"value 7 is:"<<str[6][0]<<endl;
break;
}
if (number==2)
{
getline(myfile,str[0][1],' ');
cout<<"value one is:"<<str[0][1]<<endl;
a=0;
++b;
getline(myfile,str[1][1], ' ');
cout<<"value two is:"<<str[1][1]<<endl;
getline(myfile,str[2][1], ' ');
cout<<"value three is:"<<str[2][1]<<endl;
getline(myfile,str[3][1], ' ');
cout<<"value four five is:"<<str[3][1]<<endl;
getline(myfile,str[4][1], ' ');
cout<<"value five is:"<<str[4][1]<<endl;
getline(myfile,str[5][1], ' ');
cout<<"value six is:"<<str[5][1]<<endl;
getline(myfile,str[6][1], ' ');
cout<<"value seven is:"<<str[6][1]<<endl;
break;
}
}
|