Basically, the structure is public, however when I try to store information in it in one function and then use it in a diferent function, it just gives 0. Any suggestions would be greatly appreciated. Here is the structure and the two functions that I want to use it:
struct equation {
int maxpower;
float numerators[128];
};
struct equation EQN;
void enter_filename(void)
{
printf(“Please enter the name of the file:”);
gets(filename);
}
int readEquation(struct equation EQN)
{
FILE *equationfile;
int count;
/* Opening the file and printing ERROR! if it has not opened properly */
equationfile=fopen(filename, “r”);
if (equationfile==0) {
printf(“Error! File failed to open\n”);
}
/* Reading in the integer value for the maximum power */
fscanf(equationfile, “%i”, &EQN);
printf(“Max power is %i\n”, EQN.maxpower);
/*Reading in the numerator values and storing them in the array numerators[] */
for(count=0; count<(EQN.maxpower+1); count++) { fscanf(equationfile, "%f", &EQN.numerators[count]); printf("The numerators are %f\n", EQN.numerators[count]); } if (fclose(equationfile)==-1) { printf("File failed to close\n"); } return 0; } void display_polynomial(void) { char numstring[20]; int count; printf("\nThe Equation = "); for(count=0; count<(EQN.maxpower+1); count++) { sprintf(numstring, "%G", EQN.numerators[count]); if(count!=EQN.maxpower) { printf("%sx^%i + ", numstring, (EQN.maxpower-count)); } else { printf("%s\n", numstring); } } }