function definition problem

At the end of the program where i have my function definiton it's giving me an error that says that the function definition is not allowed before '{'
Here is my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
using namespace std;

void printElements(int array[][5], int length);

int main()
{
    int employSize = 0;

    cout << "How many employees are you entering information?";
    cin >> employSize;

    int employHours[employSize][5];


    for(int i=0; i<=employSize+3; i++)
    {
        for(int j=0; j<=5; j++)
        {
            cout << "\n Enter a the number of hours\n"
            << "employee #" << i <<" worked for this day:";
            cin >> employHours[i][j];
    }

    printElements(employHours, employSize);

    return 0;

}
//*************************************************************************
void printElements(int array[][5], int length)
{
    for(int i=0; i<=length; i++)
    {
        cout << i << "| " << "\t";
        for (int j=0; j<=5; j++)
        {
            cout << array[i][j] << "\t";
        }
        cout << "\n";
    }
}


and here is the error report

C:\Users\TUFRob\Documents\EmployeeHours.cpp||In function 'int main()':|

C:\Users\TUFRob\Documents\EmployeeHours.cpp|35|error: a function-definition is not allowed here before '{' token|

C:\Users\TUFRob\Documents\EmployeeHours.cpp|45|error: expected '}' at end of input|

||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

Any help would be greatly appreciated
You're missing a "}". On your inner for loop on lines 21-25. The Error report is saying that it can't do the function definition there because there haven't been enough ending curly braces for there to be a function definition there.
Last edited on
That's because you have more opening '{' then closing '}' in main. Compiler thinks you want to define a function within main.
I would not have noticed this on my own. The error says it's on the function line. thank you though. i just wish there was a compiler that took you straight to the problem
Then we would be out of a job. You wouldn't want that, right?
Topic archived. No new replies allowed.