Needing help please....

This is a discussion on Needing help please.... within the C Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> #include <string.h> #include <stdlib.h> void readfile(char name, int grade1,int grade2,int grade3); int meangrade(int grade1,int grade2,int grade3); void ...

  1. #1
    Registered User
    Join Date
    Sep 2004

    Needing help please....

       #include <stdio.h>
       #include <string.h>
       #include <stdlib.h>
       void readfile(char name, int grade1,int grade2,int grade3);
       int meangrade(int grade1,int grade2,int grade3);
       void display(char name, int grade1,int grade2,int grade3);
       int qsort(char name, int grade1, int grade2, int grade3, int meangrade);
         struct grades
         char students[30];
         int grade1;
         int grade2;
         int grade3;
          struct grades name[30], g1, g2, g3,*gptr;
          FILE *infile;
          FILE *outfile;
         int main(int argc, char **argv) {
          char filename;
          int choice, exam;
          FILE *infile = fopen("grade.txt", "r");
          FILE *outfile = fopen("grades.txt","w");
          printf ("Please enter the filename needed:  \n");
          scanf("%c", &filename);
          printf("Please enter 1 for a specific exam to be displayed or 0 to exit. \n");
          scanf("%d", &choice);
             if (choice == 0)
          return 0;
          void readfile(char filename,char name[30],int grade1,int grade2,int grade3){
          fscanf(infile,"%c %d%d%d", name[30], &grade1, &grade2,&grade3);
          int meangrade(int grade1,int grade2,int grade3,int meangrade){
          meangrade = (grade1 +grade2 +grade3)/3;
          return meangrade;
          void display(char filename,char name[30], int grade1,int grade2,int grade3){
          int exam;
           printf("Which exam number would you like to see?    ");
           scanf("%d", &exam);
               if (exam > 3){
               printf("Please enter a valid exam number:  ");
               scanf("%d", &exam);
               fprintf(infile,"%s%d%d%d", name[30], &grade1,&grade2, &grade3);
               int qsort(struct name[30], int grade1,int grade2,int grade3, int meangrade)
               int j, max;
               for(j = 0; j < 100; ++j) {
                  if (name[j].grade1 > name[j].grade2)
                       max = name[j].grade1;
                       max = name[j].grade2;
                  if (name[j].grade3 > max)
                       max = name[j].grade3;
               return max;
    I am getting these errors... I just don't understand... especially the sort issue.. Could someone please help.

    grades.c:18: conflicting types for `qsort'
    /local/gnu/lib/gcc-lib/sparc-sun-solaris2.8/3.0.4/include/iso/stdlib_iso.h:123: previous declaration of `qsort'
    grades.c: In function `main':
    grades.c:75: warning: `struct name' declared inside parameter list
    grades.c:75: warning: its scope is only this definition or declaration, which is probably not what you want.
    grades.c: In function `qsort':
    grades.c:74: parameter name omitted
    grades.c: In function `main':
    grades.c:88: parse error at end of input

  2. #2
    Registered User
    Join Date
    Jan 2002
    change your quicksort function name to quicksort, the function name qsort is already in use.

  3. #3
    Registered User
    Join Date
    Mar 2002
    The parameter list of qsort in the declaration:

    int qsort(char name,......

    isn't the same as the parameter list in the definition

    int qsort(struct name[30], ...

    I suspect in the declaration you want

    int qsort(char name[30],.....

    and in the definition you want

    int qsort(char name[30],.....

    but then again.......
    You're only born perfect.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Completely incompetent c++'er, needing your help!!
    By andyunderpants in forum C++ Programming
    Replies: 6
    Last Post: 05-02-2009, 10:17 PM
  2. Student Needing Help (not cheating-just help)
    By Captn Japan in forum C++ Programming
    Replies: 4
    Last Post: 04-09-2003, 05:58 AM
  3. Needing Expert Advice Please
    By Virtuous in forum Game Programming
    Replies: 14
    Last Post: 03-15-2003, 02:28 PM
  4. Still Needing Help : selection sorting
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 10-14-2001, 08:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21