#include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>
usingnamespace std;
int main()
{
//Now begin reading values from the file.
ifstream inFile;
string filename;
cout << "Which file would you like to open? Include the file's name and extension: "
<< endl;
cin >> filename;
inFile.open(filename.c_str()); //attempt to open file for input
if(!inFile.fail()) //if it doesn't fail, the file exists
{
cout << "A file by the name " << filename << " exists."
<< endl;
}
int value;
int SIZE=10;
int array[10][2];
int i=0;
int j=0;
inFile >> value;
while (inFile.good()) //continue until the end of the file
{
array[i][j]=value;
for(i=0; i<SIZE; i++)
{
cout<<endl;
for( j=0; j<SIZE; j++)
{
cout<<endl;
}
}
cout <<array[i][j]<<endl;
inFile >> value;
}
inFile.close(); //closes the file
return 0;
}
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>
usingnamespace std;
int main()
{
//Now begin reading values from the file.
ifstream inFile;
string filename;
cout << "Which file would you like to open? Include the file's name and extension: "
<< endl;
cin >> filename;
inFile.open(filename.c_str()); //attempt to open file for input
if(!inFile.fail()) //if it doesn't fail, the file exists
{
cout << "A file by the name " << filename << " exists."
<< endl;
}
int value;
int ar[5][2];
int k=0;
int j=0;
if(inFile.good()) //continue until the end of the file
{
while(inFile >> value)
{
for( j=0; j<2; j++)
{
cout<<endl;
for( k=0; k<2; k++)
{
ar[k][j]=value;
cout<<ar[k][j]<<endl;
}
}
}
}
//cout<<j<<endl;
//cout <<value<<endl;
inFile.close(); //closes the file
return 0;
}
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>
usingnamespace std;
int main()
{
//Now begin reading values from the file.
ifstream inFile;
string filename;
cout << "Which file would you like to open? Include the file's name and extension: "
<< endl;
cin >> filename;
inFile.open(filename.c_str()); //attempt to open file for input
if(!inFile.fail()) //if it doesn't fail, the file exists
{
cout << "A file by the name " << filename << " exists."
<< endl;
}
int value;
int ar[5][2];
int k=0;
int j=0;
int i=0;
while(inFile.good()) //continue until the end of the file
{
inFile >> value;
for( i=0; i<5; i++)
{
cout<<endl;
for( k=0; k<2; k++)
{
ar[i][k]=value;
cout<<ar[i][k];
inFile >> value;
}
}
cout<<endl;
}
//cout<<j<<endl;
//cout <<value<<endl;
inFile.close(); //closes the file
return 0;
}