Thread: Declaration terminated incorrectly

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    11

    Declaration terminated incorrectly

    I am trying to finish up a project on file I/O, and when compiling, I get the error "Declaration Terminated Incorrectly", but it marks the opening braces for one of the functions. What am I doing wrong?

    Code follows:


    /*
    Read input from a file, calculate and print an inventory report,
    including items that need to be reordered.
    */

    #include <stdio.h>

    int GetInvData();

    int PrintReport (int *PartNo, float*Price, int *QtyOnHand,int *Reorder,int *MinOrder);

    void ReportHeaders();
    void PrintHeading();

    int main (void)
    {
    PrintHeading();
    ReportHeaders();

    GetInvData();

    return 0;
    }

    int GetInvData();
    {
    FILE *fpInvData;

    int PartNo;
    float Price;
    int QtyOnHand;
    int Reorder;
    int MinOrder;

    fpInvData = fopen("inv.dat","r");

    fscanf(fpInvData, "%04d", &PartNo);
    fscanf(fpInvData, "%2.2f", &Price);
    fscanf(fpInvData, "%4d",&QtyOnHand);
    fscanf(fpInvData, "%4d", &Reorder);
    fscanf(fpInvData, "%4d", &MinOrder);

    while (! feof(fpInvData))
    {
    PrintReport(int *PartNo, float *Price, int *QtyOnHand, int *Reorder, int *MinOrder);
    }

    printf("\n\n***End of Report***\n\n");
    fclose(fpInvData);

    }

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826

    Re: Declaration terminated incorrectly

    Originally posted by Griffin2020
    I am trying to finish up a project on file I/O, and when compiling, I get the error "Declaration Terminated Incorrectly", but it marks the opening braces for one of the functions. What am I doing wrong?

    Code follows:


    /*
    Read input from a file, calculate and print an inventory report,
    including items that need to be reordered.
    */

    #include <stdio.h>

    int GetInvData();

    int PrintReport (int *PartNo, float*Price, int *QtyOnHand,int *Reorder,int *MinOrder);

    void ReportHeaders();
    void PrintHeading();

    int main (void)
    {
    PrintHeading();
    ReportHeaders();

    GetInvData();

    return 0;
    }
    Do you see anything odd about your function call to 'PrintHeading' ... notice anything that isn't there that should be? If you're trying to just prototype, you're doing it wrong there.


    Oh, and it could be this line:


    int GetInvData();
    {
    FILE *fpInvData;
    See that nifty little semicolon?

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    11
    oops, I knew it was something silly.

    Now I get thris error, "Expression syntax in function GetInvData()"

    It tags the line:
    PrintReport(int *PartNo, float *Price, int *QtyOnHand, int *Reorder, int *MinOrder);

  4. #4
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Do you define PrintReport somewhere?

    PrintReport() should return an int, but I don't think that's the problem...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > PrintReport(int *PartNo, float *Price, int *QtyOnHand, int *Reorder, int *MinOrder);


    Duh. Of freeking course it's going to give you an error! You're not CALLING this function there, you're freeking prototyping it again! You don't use "int *" and all that crap when you're actually making a function call.

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    11
    Yes, I define it earlier (the initial post has the rest of the code), and it does return an integer.

    Thanks in advance.

  7. #7
    Registered User
    Join Date
    Mar 2002
    Posts
    11
    Okay..but if I do not specify the parameters when calling the function, it tells me not enough parameters....

  8. #8
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by Griffin2020
    Yes, I define it earlier (the initial post has the rest of the code), and it does return an integer.

    Thanks in advance.
    No, you only made the protype like this:
    Code:
    int PrintReport (int *PartNo, float*Price, int *QtyOnHand,int *Reorder,int *MinOrder);
    You define the function like this:
    Code:
    int PrintReport (int *PartNo, float*Price, int *QtyOnHand,int *Reorder,int *MinOrder)
    {
       ... //Whatever it do
    
       return ReturnVariable;
    }
    And as Quzah says, you are prototyping it again. Leave out the ints and only use whatever variables you want to pass to it.
    Code:
    ReturnVar = PrintReport (&PartNo, &Price, &QtyOnHand, &Reorder, &MinOrder);
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  9. #9
    Registered User
    Join Date
    Mar 2002
    Posts
    11
    Sorry, I yes, I actually defined the function, but was not having problems with the function itself, just the call.

    I got it...thanks for the help, people...
    Last edited by Griffin2020; 04-27-2002 at 12:13 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 08:13 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM