Im sorry but I have trouble understanding your code.
Code:
#include <ctype.h>
#define MAX 10
void main (void);
void function1 (void);
void function2 (void);
void main (void)
{
function1();
function2 ();
}
void function1 (void)
{
FILE *in;
char var;
float lab [MAX];
float test1, test2;
if (( in = fopen ("grades.txt", "r")) == NULL)
{
printf ("Error Opening File");
return;
}
while ((fscanf(in, "%c", &var)) != EOF)
{
printf ("%c", var);
}
printf ("\n");
fclose (in);
}
void function2 (void)
{
FILE *in;
char var;
int lab [MAX];
int counter;
int lab[50]; // make lots of space
char buffer[40]; // guarantee it holds one line
int * idx;
int i = 0;
int j;
if (( in = fopen ("grades.txt", "r")) == NULL)
{
printf ("Error Opening File");
return;
}
while(fgets(buffer,39,in)) // read the line
{
idx = buffer;
while (idx++ != ':'); // find the colon
fscanf("%d",&lab[i]); // get the number
i++;
}
for (j = 0; j < i; i++)
printf("Lab %d = %d\n", j, lab[j]);
}
(53): error C2369: 'lab' : redefinition; different subscripts
(71): error C2440: '=' : cannot convert from 'char [40]' to 'int *'
(72): error C2040: '!=' : 'int *' differs in levels of indirection from 'int'
(73): error C2664: 'fscanf' : cannot convert parameter 1 from 'const char [3]' to 'FILE *'