Well I cant get it to go with a multi-dimension array and I think that it may be easier 2 seperate arrays (maybe...). Anyways here is what I am trying and I am still getting this error:
Homework 7 (problem 1) error C2440: '=' : cannot convert from 'char *' to 'int'
Code:
int main()
{
//arrays for the first two lines of input file
char location[25], month_year[25], temp[8];
//array for each day of the month
int n = 0, status, array_number = 0;
float days[45], rain[45];
FILE *input, *output;
input = fopen("input.txt", "r");
output = fopen("output.xt", "a");
//fills in the arrays for the location and year
fgets(location, 25, input);
fgets(month_year, 25, input);
//fills in the array for the days of the month
for (status = fgets(temp, 8, input);
status != EOF;
status++)
{
int n = 0;
while (temp[n] != '\n')
n++;
sscanf(temp, "%f %f", &days[array_number], &rain[array_number]);
array_number++;
}
return 0;
}
And if I where to try the multi-dimensions (which may be easier to pass this to different functions) here is the code that I am trying for that part of it (I run into a runtime erroe when it gets to the sscanf part):
Code:
int main()
{
//arrays for the first two lines of input file
char location[25], month_year[25];
//array for each day of the month
int status, n = 0, array_number = 0;
char days[40][8], temp[8];
FILE *input, *output;
input = fopen("input.txt", "r");
output = fopen("output.xt", "a");
//fills in the arrays for the location and year
fgets(location, 25, input);
fgets(month_year, 25, input);
//fills in the array for the days of the month
for (status = 0;
status != EOF;
status++)
{
fgets(temp, 8, input);
int n = 0;
while (temp[n] != '\n')
n++;
sscanf(temp, "%f %f", &days[array_number][40]);
array_number++;
}
return 0;
}