#include<iostream>
#include<cmath>
#include<fstream>
usingnamespace std;
int main()
{
ifstream readingfile;
char file[100];
int xarray[200];
int yarray[200];
cout<<"Enter the name of your file\n";
cin>>file;
cout<<"Reading data from the file\n\n";
readingfile.open(file);
if(!readingfile)
cout<<"Error reading the file\n";
double num_elements=sizeof(xarray)/sizeof(xarray[0]);
for(int row=0;row<num_elements&&readingfile;row++){
for(int column=0;column<num_elements&&readingfile;column++){
readingfile>>xarray[row];
readingfile>>yarray[column];
cout<<xarray[row];
cout<<"\t";
cout<<yarray[column];
cout<<endl;
}
}
}
Basically Im trying to see if I could display a set of numbers from a textfile(2 columns,number of rows varies)but its displaying an extra line of random set of numbers
Thanks, im actually going to build a function populating arrays then to calculate formulas
im just trying to figure this part out (which works now, thanks again), taking one step at a time, im so new to this c++ stuff, i spend lot of time doing trial and errors learning from tutorials online, textbook and other resources