I have just gotten to a hold on a MSVisual 6.0 complier and i dont understand why im getting the following error message:
Code:
H:\Lab1\lab1.c(25) : error C2059: syntax error : ']'
H:\Lab1\lab1.c(26) : error C2059: syntax error : ']'
H:\Lab1\lab1.c(27) : error C2059: syntax error : ']'
H:\Lab1\lab1.c(28) : error C2059: syntax error : ']'
H:\Lab1\lab1.c(54) : warning C4047: '==' : 'char [31]' differs in
levels of indirection from 'const int '
the following is the revised code:
Code:
##include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100
#define LEN 31
#define WEEKS 4
#define TAX 0.2
#define TAXOVER 0.28
/*function prototypes*/
int getFile(char[MAX][LEN], int[MAX][WEEKS]);
void calcGross(int[MAX][WEEKS], int, float[MAX][3]);
void calcNet(float[MAX][3], int);
void calcTax(float[MAX][3], int);
void output(char[MAX][LEN], float[MAX][3], int);
int main(void){
char name[MAX][LEN];
int hours[MAX][WEEKS];
float pay[MAX][3];
int totName;
/*calling functions*/
totName = getFile(&name[MAX][LEN], &hours[MAX][WEEKS]);
printf("%d", totName);
calcGross(&hours[MAX][WEEKS], totName, &pay[MAX][3]);
calcTax(&pay[MAX][3], totName);
calcNet(&pay[MAX][3], totName);
output(&name[MAX][LEN], &pay[MAX][3], totName);
return 0;
}
int getFile(char name[MAX][LEN], int hours[MAX][WEEKS])
{
FILE *fempHrs;
int i;
int j;
char filename[20];
puts("Enter the file name. Ex: xxxx.txt");
gets(filename);
fempHrs = fopen(filename, "r"); /*open file and
check if there*/
if(fempHrs == NULL)
{
puts("ERROR: No Such File");
exit(0);
}
for(i=0;i<MAX;i++)
{
if ( fscanf(fempHrs," %[^:]", name[i]) == EOF )
break;
for(j=0;j<WEEKS;j++)
{
fscanf(fempHrs,"%*c%d", hours[i][j]);
} /*end for loop j*/
printf("%d", i);
} /*end for loop i*/
fclose(fempHrs);
return i;
} /*end getFile function*/
void calcGross(int hours[MAX][WEEKS], int totName, float pay[MAX][3])
{
int i;
int j;
float gross=0, reg, hrs, over;
for(i=0; i<totName; i++)
{
for(j=0; j<WEEKS; j++)
{
if(hours[i][j] <= 40)
gross = (float)hours[i][j] * 17;
else
if(hours[i][j] > 40)
{
hrs = (float)hours[i][j] - 40;
over = hrs * 25.5;
reg = 40 * 17;
gross = over + reg;
} /*end if*/
pay[i][0]+=gross;
} /*end for loop j*/
} /*end for loop i*/
return;
} /*end calcGross function*/
void calcTax(float pay[MAX][3], int totName)
{ /*function to calc Tax*/
int i;
for(i=0; i<totName; i++)
{
if(pay[i][0] < 1800)
pay[i][1] = pay[i][0] * TAX;
else
if(pay[i][0] >= 1800)
{
pay[i][1] = pay[i][0] * TAXOVER;
}
}
return;
} /*end calcTax Function*/
void calcNet(float pay[MAX][3], int totName)
{ /*function to calc netincome*/
int i;
for(i=0; i<totName; i++)
{
pay[i][2] = pay[i][0] - pay[i][1];
}
return;
} /*end calcNet Function*/
void output(char name[MAX][LEN], float pay[MAX][3], int totName)
{
int i=0;
puts("*********************************************");
puts("* Monthly Pay Record *");
puts("*********************************************");
for(i=0;i<totName;i++)
{
printf("\t%.2f \t%.2f \t%.2f", &pay[i][0], &pay[i][1], &pay[i][2]);
}
return;
}
thank you for any help
ps. i couldn't edit my first message as a unregistered user sorry.