First off,
Quote:After re-looking over the code I corrected some things and sure enough the function that I thought was causing issues was not where I had the error.
You are aware, I hope, that error messages generally include a line number and a description of the problem? If they don't make sense, just fix the first one; sometimes a missing semicolon or whatever can cause a lot of confusion for the compiler, which doesn't read code in a very "human" way at all.
Quote:Original post by toogreat4u
However names is defined as the following
*** Source Snippet Removed ***
There we see most of your problems.
The first problem is you are trying to use arrays of characters to represent text. In C++, we represent text with instances of std::string. The second problem is that you're using an array with some "maximum size" to represent a set of things that clearly doesn't have a natural restriction on its size. In C++, we represent sequences of unknown length with a standard library container, such as std::vector. The third problem is that you are passing two parallel structures of data to represent the students. In C++, we create structured data to represent a single thing, and make a container of structures, instead of several parallel containers.
Thus, we would do something like
struct Student { std::string name; // The number of grades per student *does* appear to be a specific value // for a good reason: that's how many subjects are being taught to the class. // Of course, you might decide that this restriction is not a useful one, // and use a container here as well. int grades[NUM_GRADES];};void printDatabase(const std::vector<Student>& students) { // ...}
But that simply addresses some of your problems, and not your question. :)
Quote:I can not remember how your suppose to pass the char array into the function.
You are, in fact, doing it correctly. You have other errors (which you would have to fix even with modern C++ tools), as follows:
1) "NUM_STUDENTS" is mis-typed in one place.
2) To index into a multi-dimensional array, you must index each dimension separately: arr[j][k], not arr[j, k]. The latter means the same thing (in this case) as arr[k], which just gives you an array. (Passing an array to the operator<< overload for std::cout causes it to decay to a pointer, so you end up printing the pointer value.) If you don't understand why that is,
read this.
3) (Possibly) Ensure that you are either 'using namespace std;', or explicitly qualify things from the std namespace with 'std::'. Also, note that 'setw' comes from <iomanip>, not <iostream>.
Quote:Original post by DevFred
The initializer on the right does not fit the data type on the left.
You are correct, but strangely, this doesn't seem to matter to the compiler. I assume that nested braces are more or less ignored for aggregate initializers.