What I'd really like to be able to do is import data from text files into my programs. I am able to do this on Sun terminals at school, but not with Dev-Bloodshed at home. This is an example of a program that should open a text file and print out the numerical data in it. The text file is attached.
Code:
#include <iostream.h>
#include <math.h>
#include <fstream.h>
#include <iomanip.h>
#include <stdlib.h>
int main()
{
//Variable IDs
double a[100];int i,j,N,his[50]={0};
cout<<"Type in the number of data points"<<endl;
cin>>N;
//Read in data from file3.dat
if(N<=64)
{ //Read in data from file3.dat
ifstream source;
source.open("file3.dat");
if(!source)
{cerr<<"Can't open data file."<<endl;
system("PAUSE");
return(1);}
for(i=0;i<N;i++)
{source>>a[i];}
source.close();
}
else
{cerr<<"Too many data points."<<endl;
system("PAUSE");
return (1);}
//Print out data before sorting
int k,colnum=8;
for(j=0;j<N;j=j+colnum)
{k=colnum;
if((j+colnum)>N)
{k=N-j;}
for(i=0;i<k;i++)
{cout<<setw(8)<<a[i+j];}
cout<<endl;}
system("PAUSE");
return 0;}