I'm almost finished coding the last of my C program on stock inventory
but in the last two functions (one being my main function and the other a void function)
the compiler gives an error stating that there a Parse Issue
and that an expected identifier or "(" is missing in main.c

..
I've already opened and closed my functions with '{, }' and this errpr doesnt exist in my other functions
any idea on what the error could be?

If you show us the code, we can tell you waht's missing. If I had to guess, you're missing a closing bracket, semi-colon or similar such syntax.

Edited 3 Years Ago by Moschops

void Final();
{
    printf ("\n\n                .|||||||||||||.\n");
    printf ("            .|||||||||||||||||||||.\n");
    printf ("         .|||||||'|||||||||||'|||||||.\n");
    printf ("       .||||||||' '|||||||||' '||||||||.\n");
    printf ("      .|||||||||   |||||||||   |||||||||.\n");
    printf ("     .||||||||||   |||||||||   ||||||||||.\n");
    printf ("    .|||||||||||   |||||||||   |||||||||||.\n");
    printf ("    .|||||||||||   |||||||||   |||||||||||.\n");
    printf ("    :|||||^|||||. .|||||||||. .||||||^||||:\n");
    printf ("    '||||| ||||||.|||||||||||.||||||| ||||'\n");
    printf ("    '||||| |||||||||||||||||||||||||| ||||'\n");
    printf ("     '|||||.                        .||||'\n");
    printf ("      '|||||.                     .|||||'\n");
    printf ("        '||||.                   .||||'\n");
    printf ("          '|||||.             .|||||'\n");
    printf ("             '||||||||||||||||||||'\n");
    printf ("                '||||||||||||||'\n");
    printf ("\n\n\t\tHave a nice day!");
}
//--------------------------------------------------------------------------------------------

int main ();
{

    welcome();

    int menu();
    {
        int opt1;

        system ("cls");
        printf ("1. Rent\n2. Return\n0. Exit\n\n");
        printf ("Please select the desired option:  ");
        scanf ("%d", &opt1);
        while (opt1!= 1&& opt1!= 2&& opt1!= 0)
        {
            printf ("\nThat is not an option. Try again.\n ");
            getchar();
            menu();
        }
        if (opt1== 1)
        {
            Rents();
            Info();
            Stock();
            Transactions();
        }
        else if (opt1== 2)
        {
            Returns();
            Info();
            Stock();
            Transactions();
        }
        else if (opt1== 0)
        {
            Final();
            printf ("\n\n\t\tPlease have a nice day.\n\n\t\tPress any key to exit.");
            getchar();
        }
    }
    menu();
    //--------------------------------------------------------------------------------------------

}

These are the two functions that are giving problems :(

every other function has already been declared with no problems
but only these two functions have problems

this is only a part of an entire code

One way to debug this is to delete some blocks of the code and recompile. If the error still exists, put back the deleted blocks and delete the next set of code blocks. Recompile agian. If the error still persist, keep doing it until it compiles. Then the deleted blocks contain the error. Now, narrow it down by delete a smaller chunk of the code.

PS: Are you sure that you declare line 1 correctly? Why do you have a semi-colon and then the following line starts with an open curly bracket? Maybe this is C syntax???

Edited 3 Years Ago by Taywin

You have misunderstood the difference between declaring a function and actually writing it.

This

int somefunction();

declares the existence of a function, named somefunction. Note that semi-colon.

This

int somefunction()
{
  // function code in here
    int x;
    return x;
}

is the actual function. There is no semi-colon on the first line.

So in your code, you declare the existence of a function named Final, and you declare the existence of a function named main, but you never write those functions. You do, however, put in lots of code that isn't part of those functions.

Long story short - you've got your semi-colons wrong. Go back and double-check how to declare (prototype) functions and how to actually write (define) them. Lines 1, 24, 29.

Also, you seem to be trying to write the function menu (line 29 onwards) inside another function (the function named main). You cannot do this. You cannot write functions inside other functions.

Also, are you trying to call the function menu from inside the function menu (line 41)? This is a really bad idea here. This function has no business being recursive, and since this section is inside a while loop that will keep going round until the user enters a correct value, makes no sense at all here.

Edited 3 Years Ago by Moschops

I see what you mean
thank you sooo much
I fixed it and took the menu function out and started writing it outside

that was very eye-opening :)

PS: Are you sure that you declare line 1 correctly? Why do you have a semi-colon and then the following line starts with an open curly bracket? Maybe this is C syntax???

You were right taywin :)
there was something wrong.

When you finish moving menu() and etc., outside of the other functions, then post your new code up, if it still has problems.

That way we'll be able to see the new code, and be on the same pew.

This article has been dead for over six months. Start a new discussion instead.