I am trying to input a data file into C++ such that it will appear as 2 arrays of maximum value 100... so far, this is what I have...

void readfile(double x[], double y[], double sigma[], int * entries)
{
/* read data into x[] and y[]
fill sigma[] with 1's
determine the value of entries */
char name[40];
FILE *data;
*entries=0;
printf("Enter the name of the data file: ");
scanf("%40s",name);
if ((data=fopen(name,"r"))==NULL) {
printf("Can't open file %s.\n",name);
exit(1); // Exits program
}
// Assume data file contains 2 columns of data with no header
while (*entries<MAXDATA &&
fscanf(data,"%lf %lf",&x[*entries],&y[*entries])==2) {
sigma[*entries]=1;
(*entries)++;
}
if (fclose(data)) printf("Error in closing data file.\n");
return;
}

I am a student learning to use this program, and I could really use some help! Thanks everyone...

Your code is C. This is a C++ forum.

It looks like it should do what you ask.

Does it run? Does it give the results you want? What's your question?

And, when you post code, please put it between code tags, thusly

[code]

your code goes here

[/code]

You want to know how this program works????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.