this is for school and im getting a few error messages that are confusing me. really am clueless as to why they are occuring?
Code:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
int get_int(char msg[]);
double get_double(char msg[]);
void display(char hauler[],double tot_trash[],int i);
int main()
{
char hauler[40][40];
char msg[200];
char end = ' ';
int trash = 0;
int l_trash;
int i = 0;
double tot_trash[40] = {0.0};
double rate;
double total = 0.0;
while(end != 'Y')
{
printf("What is your name? %s\n",hauler);
gets(hauler[i]);
while(trash != 0)
{
strcpy(msg,"Enter how much trash you took out(0 to stop)? \n");
trash = get_int(msg);
tot_trash[i] += trash;
}
strcpy(msg,"How Much trash did you dump last month? \n");
l_trash = get_int(msg);
if(trash < l_trash)
total = 350.00 * trash;
else
{
strcpy(msg,"Enter the Tonnage Rate? \n");
rate = get_double(msg);
total = 350.00 * l_trash;
total += (350.00 + rate) * (trash - l_trash);
}
i++;
printf("Do you want to enter a new hauler(y or n)? %s\n",end);
end = getch();
end = toupper(end);
display(hauler[][],tot_trash[],i);
return 0;
}
int get_int(char msg[])
{
char buf[40];
printf(msg);
gets(buf);
return atoi(buf);;
}
double get_double(char msg[])
{
char buf[40];
printf(msg);
gets(buf);
return atof(buf);
}
void display(char hauler[],double tot_trash[],int i)
{
for(int j = 0;j<i;j++)
{
printf("Hauler: %s spent %d\n",hauler[j],tot_trash[j]);
}
}
c:\skool\Cpt235_1\proj 1\prog_1.cpp(53): error C2059: syntax error : ']'
c:\skool\Cpt235_1\proj 1\prog_1.cpp(58): error C2601: 'get_int' : local function definitions are illegal
c:\skool\Cpt235_1\proj 1\prog_1.cpp(66): error C2601: 'get_double' : local function definitions are illegal
c:\skool\Cpt235_1\proj 1\prog_1.cpp(74): error C2601: 'display' : local function definitions are illegal
c:\skool\Cpt235_1\proj 1\prog_1.cpp(80): fatal error C1075: end of file found before the left brace '{' at 'c:\skool\Cpt235_1\proj 1\prog_1.cpp(11)' was matched
thanks