Ok so here is the code I've written already, as well as the errors I get when I try to build. Please help me figure out what the problem is!
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#define COMPANY "Rocklin Realty"
#define TRUE 1
#define TAB 25
void setagents(double *a, int c);
void total_sales(double *m, char **cal, int c);
void agent_sales(double *m, char **cal, int c);
void valid_date(char *date, int min_yr, int max_yr);
void titles(void);
int headings(void);
int menu(void);
void add(void);
int quit(void);
void message(char *msg);
int menuvalid(int min, int max, char item[]);
char *names[] = {"Larry Lister", "Sue Sales", "Eva Escrow", "Morley Money", "Pete Profit" };
typedef struct
{
char aname[15], date[9];
int acode;
double price;
} REALTOR;
#define clrscr() system("cls")
int main()
{
int key, more = TRUE;
do
{
key = menu();
switch (key)
{
case 1: add(); break;
case 2: total_sales(); break;
case 3: agent_sales(); break;
case 4: more = quit(); break;
default: message("\nError in selection\a");
}
}
while (more);
return 0;
}
/* ================================================================ */
int menu()
{
int choice;
titles();
printf("1 = Add Records\n", TAB, ' ');
printf("2 = Report Total Sales\n", TAB, ' ');
printf("3 = Report Agent Sales\n", TAB, ' ');
printf("\4 = Quit\n", TAB, ' ');
choice = menuvalid(1, 4, "choice");
return(choice);
}
/* ================================================================ */
/**/
void add()
{
double agents[6];
double price;
int aname, c, more, items, key;
char choice;
REALTOR s;
FILE *fp;
fp = fopen("sales.dat", "w+b");
if (fp == NULL)
{
message("Error opening sales.dat\a");
return;
}
fseek(fp, 0L, SEEK_END);
c = (int)ftell(fp) / sizeof(s);
setagents(agents,6);
do
{
printf("Enter an agent code (1-5): ");
scanf("%d%*c", s.aname);
printf("Enter sale date for %s: ", names[aname-1]);
gets(s.date);
printf("Enter the sale price : ");
scanf("%lf%*c", s.price);
}
/* ================================================================ */
void titles()
{
clrscr();
printf("%*c %s\n\n", TAB, ' ',COMPANY);
/* ================================================================ */
void message(char *msg)
{
printf("%s, press Enter key to continue\n", msg);
getchar();
}
/* ================================================================ */
int quit()
{
int c, more = TRUE;
c = prompt("\nTerminate program");
if (c == 'Y')
{
clrscr();
message("\nRocklin Realty Sales Database terminated successfully");
more = FALSE;
}
return more;
}
/* ================================================================ */
void valid_date(char *date, int min_yr, int max_yr)
{
int mm, dd, yy, max_dd, good;
char msg[80];
do
{
printf("Enter the date (mm/dd/yy), press RETURN to quit: ");
gets(date);
if (!date[0]) return;
good = parsedate(date, &mm, &dd, &yy);
if (!good)
{
message("Date must be in mm/dd/yy format\a");
continue;
}
if (yy < min_yr || yy > max_yr)
{
sprintf(msg, "Year out of range %d to %d\a", min_yr, max_yr);
message(msg);
good = FALSE;
continue;
}
if (mm < 1 || mm > 12)
{
message("Month out of range\a");
good = FALSE;
continue;
}
if (mm==4 || mm==6 || mm==9 || mm==11) max_dd = 30;
else if (mm==2)
{
if (ISLEAP(1900+yy)) max_dd = 29;
else max_dd = 28;
}
else max_dd = 31;
if (dd < 1 || dd > max_dd)
{
message("Day out of range\a");
good = FALSE;
continue;
}
}
while (!good);
}
/* ================================================================ */
int menuvalid(int min, int max, char item[])
{
int n;
char buffer[80];
printf("Enter the %s %d to %d: ", item, min, max);
gets(buffer);
n = atoi(buffer);
while (n < min || n > max)
{
message("\nRange Error\a");
printf("Enter the %s %d to %d: ", item, min, max);
gets(buffer);
n = atoi(buffer);
}
return(n);
}
/* ================================================================ */
Errors:
Error 1: error C2660: 'total_sales' : function does not take 0 arguments
Error 2: error C2660: 'agent_sales' : function does not take 0 arguments
Error 3: error C2062: type 'void' unexpected
Error 4: error C2143: syntax error : missing ';' before '{'
Error 5: error C2601: 'message' : local function definitions are illegal
Error 6: error C2601: 'quit' : local function definitions are illegal
Error 7: error C2601: 'valid_date' : local function definitions are illegal
Error 8: error C2601: 'menuvalid' : local function definitions are illegal
Error 9: fatal error C1075: end of file found before the left brace '{' at 'c:\documents and settings\janelle\my documents\homework april 22-29\c programming\final exam\final exam\final.cpp(80)' was matched c:\documents and settings\janelle\my documents\homework april 22-29\c programming\final exam\final exam\final.cpp