expected ‚)‚ before ‚eTable‚

This is a discussion on expected ‚)‚ before ‚eTable‚ within the C Programming forums, part of the General Programming Boards category; i'm receiving this error on several subprograms in the same place in the program. i can't figure out what is ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    42

    expected ‚)‚ before ‚eTable‚

    i'm receiving this error on several subprograms in the same place in the program. i can't figure out what is causing it...any help?

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    void SelectionSort(struct employee eTable[], int numEntries, FILE *outFile){
    
    
                    struct employee temp[1];
                    int maxPt;
    
                    int j, k;
                    for(j = (numEntries -1); j > 0; j--){
                            maxPt = 0;
                            for(k = 1; k <= j; k++)
                                    if(strcmp(eTable[k].dept, eTable[maxPt].dept) > 0)
                                            maxPt = k;
    
                            temp = eTable[maxPt];
                            eTable[maxPt] = eTable[j];
                            eTable[j] = temp;
                    }
    
    
                    fprintf(outFile, "\n\n********************SORTED DATA FROM ''D'' OPTION SORT**************************\n\n\n");
    
                    for(k=0; k < numEntries; k++){
                            fprintf(outFile, "%-10s\t%-12s\t%-20s\t%-4.2f\t%-10s\n", eTable[k].surname, eTable[k].given, eTable[k].dept, eTable[k].payRate, eTable[k].eyeColor);
                    }
    
            }

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    2,697
    Are you including the include file for the structure when you compile this file?

    If so please post that file as well.

    Jim

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    42
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #define MaxSize 30
    
    
    
     //Define struct//
    struct employee {
            char surname[10];
            char given[12];
            char dept[20];
            float payRate;
            char eyeColor[8];
    };
    
    
    
    void SelectionSort(struct employee table[], int, FILE*);
    void SelectionSort2(struct employee table[], int, FILE*);
    void SelectionSort3(struct employee table[], int, FILE*);
    //void TemplateSelectionSort(MyType, int, FILE*);
    
    int main(){
    
            FILE *inFile;
            FILE *outFile;
    
            char resp = 'Y';
            char fileInName[20];
            char fileOutName[20];
    
            int k;
            int numRecords = 0;
    
            //Prompting user for Input file//
            while(resp == 'Y' || resp == 'y'){
                    printf("Please enter the file you'd like to read from: ");
                    scanf("%s", fileInName);
                    if((fopen(fileInName, "r")) == NULL){
                            printf("Could not open requested file. Would you like to enter another file? [Y/N]: ");
                            scanf("%*c %c", &resp);
                    }
                    else {
                            inFile = fopen(fileInName, "r");
                            break;
                    }
                    if(resp == 'n' || resp == 'N')
                            exit(1);
    
            }
    
          //Prompting user for Output File//
    
            printf("Please enter the file you'd like to write to: ");
            scanf("%s", fileOutName);
            if(fopen(fileOutName, "r") != NULL){
                    printf("The file you are attempting to write to already exists! Overwrite?? [Y/N]: ");
                    scanf("%*c %c", &resp);
                    if(resp == 'Y' || resp == 'y')
                            outFile = fopen(fileOutName, "w");
                    else {
                            printf("Aborting program to avoid overwriting existing file!!");
                            exit(1);
                         }
             }
    
    
    
            if(fopen(fileOutName, "r") == NULL)
                    outFile = fopen(fileOutName, "w");
    
            struct employee table[MaxSize];
    
            for(k=0;(fscanf(inFile, "%s%s%s%f%s", table[k].surname, table[k].given, table[k].dept, &table[k].payRate, table[k].eyeColor) != EOF); k++){
                    numRecords++;
            }
    
            for(k=0; k<numRecords; k++){
                    fprintf(outFile, "%-10s\t%-12s\t%-20s\t%-4.2f\t%-10s\n", table[k].surname, table[k].given, table[k].dept, table[k].payRate, table[k].eyeColor);
            }
    
    
            SelectionSort(table, numRecords, outFile);
            SelectionSort2(table, numRecords, outFile);
            SelectionSort3(table, numRecords, outFile);
            TemplateSelectionSort(table, numRecords, outFile, "surname");
            TemplateSelectionSort(table, numRecords, outFile, "dept");
    
    }

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    2,697
    First is your SelectionSort() function in a separate file from where you defined your structure?

    Second in your SelectionSort() function what is the purpose of an array with 1 element?
    Code:
                    struct employee temp[1];
    You probably don't want this to be an array.

    After fixing this it seems to compile after I comment out the functions not provided.

    Jim

  5. #5
    Registered User
    Join Date
    Feb 2011
    Posts
    42
    Sorry for the delay in response.

    Yes, SelectionSort() function is in a separate file from the definition of the structure.

    And I eliminated the array from that line of code. Thanks for the advice.

    However, when compiled now, i get the following errors. (And the other error went away, for now):

    SelectionSort.c:5: error: array type has incomplete element type
    SelectionSort.c:5: warning: ‚struct employee‚ declared inside parameter list
    SelectionSort.c:5: warning: its scope is only this definition or declaration, which is probably not what you want
    SelectionSort.c: In function ‚SelectionSort‚:
    SelectionSort.c:8: error: storage size of ‚temp‚ isn‚t known
    SelectionSort.c:8: warning: unused variable ‚temp‚

  6. #6
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,649
    OT: You can fix your funky-azz symbols in the errors

    Code:
    SelectionSort.c:5: warning: ‚struct employee‚ declared inside parameter list
    by setting your terminal program (PuTTY perhaps?) to use Unicode character encoding.

  7. #7
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    The original error message ... expected ) before "table" probably indicates a missing ) someplace earlier in the code, possibly not even in the same source page. If your IDE has a bracket matching feature it should show you the ( that doesn't have a mate. If not, you will have to start working backwards through your code until you find it.

  8. #8
    Registered User
    Join Date
    May 2010
    Posts
    2,697
    Also posting the code for SelectionSort.c would help, since all the remaining errors are in that file.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. expected identifier
    By ozu in forum C Programming
    Replies: 5
    Last Post: 08-21-2010, 06:32 PM
  2. BAH! expected `;' before 'else'
    By Chef in forum C++ Programming
    Replies: 19
    Last Post: 10-03-2008, 01:37 PM
  3. expected `)' before str... help!
    By dingobiatch in forum C++ Programming
    Replies: 10
    Last Post: 05-15-2008, 10:20 AM
  4. non expected output
    By c++.prog.newbie in forum C Programming
    Replies: 2
    Last Post: 09-27-2004, 05:41 PM
  5. Expected error
    By ZakkWylde969 in forum C Programming
    Replies: 9
    Last Post: 06-17-2003, 10:51 AM

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