| | |
Need help with struct records!
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Feb 2008
Posts: 59
Reputation:
Solved Threads: 0
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!
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
c Syntax (Toggle Plain Text)
#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
nelledawg you could clearly see from the error message what the problem with the code is. Lets have a look at your some of your error message and the solutions for that error.
What does it say, its saying that total_sales function does that takes 0 number of arguments , which is right , because youm have prototypes the total_sales function as taking 3 arguments
And you are missing some braces her and there. And you need to sit down check the function prototypes, may be will reduce a hell lot of errors.
ssharish
C Syntax (Toggle Plain Text)
Error 1: error C2660: 'total_sales' : function does not take 0 arguments
What does it say, its saying that total_sales function does that takes 0 number of arguments , which is right , because youm have prototypes the total_sales function as taking 3 arguments
C Syntax (Toggle Plain Text)
void total_sales(double *m, char **cal, int c);
And you are missing some braces her and there. And you need to sit down check the function prototypes, may be will reduce a hell lot of errors.
ssharish
•
•
Join Date: Feb 2008
Posts: 59
Reputation:
Solved Threads: 0
Ok but when I put the arguments in I get even more errors.
Ex:
I just don't know how I'm supposed to put the arguments in the case correctly.
Ex:
c Syntax (Toggle Plain Text)
case 2: total_sales(double *m, char **cal, int c); break;
I just don't know how I'm supposed to put the arguments in the case correctly.
ohh nelledawg, where did you get the code from. It donst look like that you wrote the code. You need to look into some basic before you program anything like this. You are usinfg some advance pointer types which you need to under stand. Let me should a simple example on how to send arguments. Look at the following code. And arguments is something which you send it a function. These values will then we used in the function for it own processing. So might have been decided for that function does and you should be knowing needed to be sending. So for example
The above ius function which takes two integer arguments a & b. Now i know that function takes two integer argument and it works on that two argument. So when I call that function i call it through this way
Now sit down and look at your code and see what arguments should be sent to the total_sales function.
ssharish
C Syntax (Toggle Plain Text)
int sun( int a, int b);
The above ius function which takes two integer arguments a & b. Now i know that function takes two integer argument and it works on that two argument. So when I call that function i call it through this way
C Syntax (Toggle Plain Text)
sum(1, 2); or int a = 10; int b = 20; sum(a, b);
Now sit down and look at your code and see what arguments should be sent to the total_sales function.
ssharish
nelledogg,
i just gave you postive comment because i thought you wrote that nice code yourself. you said "here is the code i have written"
but then you obviously dont even know how to pass arguments into a simple function, as evidenced by your attempt
so you DIDNT write any of this code, did you?
because the rest of your code is using far more advanced concepts than passing simple arguments to a function.
now why don't you tell the truth about what's going on here?
i just gave you postive comment because i thought you wrote that nice code yourself. you said "here is the code i have written"
but then you obviously dont even know how to pass arguments into a simple function, as evidenced by your attempt
case 2: total_sales(double *m, char **cal, int c); so you DIDNT write any of this code, did you?
because the rest of your code is using far more advanced concepts than passing simple arguments to a function.
now why don't you tell the truth about what's going on here?
•
•
•
•
hey by checking above posts, it reminds me of a concept in C, default arguments!.
I am not sure is there any concept of default arguments?
Thanks
ssharish
hi,
the first thing i noticed is there's no total_sales function, if u can c the total_sales just lemme know, so i wonder how case 2 gonna work, n just @ a 1st sight, there r more prototypes than the cases, maybe if u send us ur source we might help u figuring out whats wrong whith that, plus it will make us a gd exercice,
right guys?
the first thing i noticed is there's no total_sales function, if u can c the total_sales just lemme know, so i wonder how case 2 gonna work, n just @ a 1st sight, there r more prototypes than the cases, maybe if u send us ur source we might help u figuring out whats wrong whith that, plus it will make us a gd exercice,
right guys?
I'm a Barbie Girl, in a Barbie world, life in plastic, it's fantastic, you can brush my hair, undress me everywhere, Imagination, Life is your creation
•
•
•
•
hi,
the first thing i noticed is there's no total_sales function, if u can c the total_sales just lemme know, so i wonder how case 2 gonna work, n just @ a 1st sight, there r more prototypes than the cases, maybe if u send us ur source we might help u figuring out whats wrong whith that, plus it will make us a gd exercice,
right guys?
how about you NOT talk like a 12-year-old texting message to your friends during recess, mmkay?
.
Last edited by jephthah; Jun 25th, 2008 at 4:21 pm.
![]() |
Similar Threads
- Declaring an array of records in MC++ (C++)
- stuck in Menu loop!! (C)
- Array Struct Sort Help!! Urgent! (C)
- array struct display?? (C)
- Data stored in Records (C#)
- Trouble Reading Records (C++)
- reading records from a file (C++)
- fstream and struct question (C++)
Other Threads in the C Forum
- Previous Thread: How to create an MP3 player.
- Next Thread: Reversing doubly linked list?
| Thread Tools | Search this Thread |
adobe ansi api array arrays asterisks binarysearch calculate centimeter char convert copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax directory dynamic fflush file fork forloop frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop initialization interest kernel km linked linkedlist linux linuxsegmentationfault list lists locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socketprograming stack standard string strings structures systemcall testautomation turboc unix user variable voidmain() wab win32api windows.h






