structures and functions HELP!!

I can't get this to compile. This is my first time with structures with arrays and functions and I don't understand this compiler error. Please help!

Error (line 133): a function-definition is not allow here before "{" token

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include <cstdlib>
#include <iostream>
#include <iomanip>

using namespace std;

//typedef to define new MyString datatype
const int SIZE_1 = 20;
const int SIZE_2 = 5;
typedef char MyString[SIZE_1];

//define structures Date and StudentInfo globally for Pass by Value
struct Date {
              int month;
              int day;
              int year;
            };
struct StudentInfo {
                     MyString fname;
                     char mInitial;
                     MyString lname;
                     int test1;
                     int test2;
                     float average;
                     Date gradDate;
                   };

//Prototypes
void Input(StudentInfo[]);
void Average(StudentInfo[]);
void Output(StudentInfo[]);


int main()
{
    StudentInfo students[SIZE_1];
        
    Input (students);
    Average (students);
     
    cout << endl << endl;
    cout << left << "Student Name\t\t" << setw(8) << "Test1" << setw(8) << "Test2";
    cout << setw(8) << "Ave" << setw(10) << "Grad Date" << endl;
    
    Output (students);
         
    system("PAUSE");
    return EXIT_SUCCESS;
}
    
/******************************************************************************  
Function for input that returns all elements of the structure
******************************************************************************/
void Input (StudentInfo mystudent[])
{
    for (int i = 0; i < SIZE_2; i++)
    {
        cout << "\nEnter the following info for student #" << i+1 << ":\n";
        cout << "First Name: ";
        cin >> mystudent[i].fname;
        cout << "Middle Initial: ";
        cin >> mystudent[i].mInitial;
        cout << "Last Name: ";
        cin >> mystudent[i].lname;
        do
        {
              cout << "Test 1 score: ";
              cin >> mystudent[i].test1;
              
              if (mystudent[i].test1 >= 0 && mystudent[i].test1 <= 100)
                   break;
              else
                   cout << "Invalid test score. Must be between 0 - 100. Try again.\n";
        } while (1);
       
        do
        {
              cout << "Test 2 score: ";
              cin >> mystudent[i].test2;
              
              if (mystudent[i].test2 >= 0 && mystudent[i].test2 <= 100)
                   break;
              else
                   cout << "Invalid test score. Must be between 0 - 100. Try again.\n";
        } while (1);
     
        do
        {
              cout << "Month of graduation (MM): ";
              cin >> mystudent[i].gradDate.month;
              
              if (mystudent[i].gradDate.month > 0 && mystudent[i].gradDate.month < 13)
                   break;
              else
                   cout << "Invalid Month. Must be between 1 - 12. Try again.\n";
        } while (1);
  
        do
        {
              cout << "Day of graduation (DD): ";
              cin >> mystudent[i].gradDate.day;
              
              if (mystudent[i].gradDate.day > 0 && mystudent[i].gradDate.day < 32)
                   break;
              else
                   cout << "Invalid Day. Must be between 1 - 31. Try again.\n";
        } while (1);
     
        do
        {
              cout << "Year of graduation (YYYY): ";
              cin >> mystudent[i].gradDate.year;
              
              if (mystudent[i].gradDate.year > 2012)
                   break;
              else
                   cout << "Invalid Year. Must be 2013 or a future year. Try again.\n";
        } while (1);
        
}

/******************************************************************************
function for finding the average
******************************************************************************/
void Average(StudentInfo mystudent2[])
{
        for (int i = 0; i < SIZE_2; i++)
        {   
            mystudent2[i].average = (mystudent2[i].test1 + mystudent2[i].test2)/2.0;
        } 
        
}
    
/******************************************************************************
function for output of all student info in the structure array
******************************************************************************/ 
void Output(StudentInfo mystudent3[])
{
    for (int i = 0; i < SIZE_2; i++)
    {
        cout << left << mystudent3[i].fname << " " << mystudent3[i].mInitial << " ";
        cout << mystudent3[i].lname << "\t\t" << setw(8) << mystudent3[i].test1;
        cout << setw(8) << mystudent3[i].test2 << setw(8) << mystudent3[i].average;
        cout << mystudent3[i].gradDate.month << "/";
        cout << mystudent3[i].gradDate.day << "/" << mystudent3[i].gradDate.year;
        cout << endl;    
    } 
}
In the definition of Input() you lack the closing bracket of the for loop. The closing bracket of the function is read as the for's and makes the following definitions be part of Input()'s body.
thank you Maeriden! that was a silly miss on my part.
Topic archived. No new replies allowed.