Multi-Dementional array help

I have this homework assignment that I have to do but it keeps telling me that I can't pass the 2-D array by refernce. How else would I be able to make a function handle the array initialization part? Help please
here's the 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
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
/***************************************************************
*  Homework 11: Graded In-Class Assignment (11/3/11)
*
*  Modify the In-Class Exercise-3 (11/3/11) so that
*  1.  The information entry is handled by an appropriate function.
*      The data will be stored in a two dimensional array of type string.
*  2.  Program saves/writes the entered information in a tabular format
*      to a file, using a function.
*  3.  All functions will be called by main( ).
*
*  DUE:  11/10/2011
*****************************************************************/

/*********************************************
* file name: gradedinclass.cpp
* programmer name: Hayder Sharhan
* date created: 11_9_11
* date of last revision: 
* details of the revision: 
* short description: using 2d arrays with functions
**********************************************/

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

// Declared constants
const int NUMBER_STUDENTS = 5;
const int NUMBER_VALUES = 3;

// Function prototypes
void programDescription();
// Add function prototypes here
void loadArray(string&);
void writeArray();

int main()
{
	// Program description
	programDescription();

	// Declare variables
	string stuInfo[NUMBER_STUDENTS][NUMBER_VALUES];

	// Initialize variables -- load array data from user input
	loadArray(stuInfo);


	// Display results
	writeArray(stuInfo);



	return 0;
}

void programDescription()
{
	cout << "This program reads student grade information from" << endl
		 << "the user and displays it in a tabular format" << endl;
}

// Function implementation for loadArray()
void loadArray(string& stuInfo[NUMBER_STUDENTS][NUMBER_VALUES])
{
	for (int i = 0; i < NUMBER_STUDENTS; i++)
	{
		for (int j=0; j < NUMBER_VALUES; j++)
		{
			cout << "\nEnter information for student " << i + 1 << ": " << endl;
			cout << "\tLast Name>> ";
			cin >> stuInfo[i][j];
			cout << "\tOverall Average>> ";
			cin >> stuInfo[i][j];
			cout << "\tLetter Grade>> ";
			cin >> stuInfo[i][j];
		}
	}
}


// Function implementation for writeArray()
void writeArray(string stuInfo[NUMBER_STUDENTS][NUMBER_VALUES])
{
	
	// Display table header line
	cout << endl
		 << "Last          Overall          Letter" << endl
		 << "Name          Average          Grade" << endl
		 << "----          -------          ------" << endl;
	// Display table data
	for (int i = 0; i < NUMBER_STUDENTS; i++)
	{
		cout << left << setw(15);
		for (int j = 0; j < NUMBER_VALUES; j++)
		{
			cout << stuInfo[i][j] << setw(20);
		}
		cout << endl;
	}

}
Topic archived. No new replies allowed.