error: invalid types 'char[int]' for array subscript

Hello all,

I am developing a program that is menu-driven, allowing for the following menu choices:

Load an exam: Loading an exam should prompt the user for an exam file. If no file exists, it should allow the user to specify a different file. Upon a successful load of an exam, the user should be presented with the menu again.

Display exam: The program should simply display each question, its point value, and the answer to the screen. Upon displaying the exam to the screen, the user should be presented with the menu again.

Quit: Quit the program gracefully by displaying a "thank you" message to the user, and ensure that all files have been closed along with any other housekeeping that should be done as the program shuts down.

The code has gotten too big to post here, so here's the link to the codepad: http://codepad.org/bXp3T8Wq

I ran this in codepad, also in DevC++, and get the following output error:
1. In function 'void printDisplayExam()':
2. Line 130: error: invalid types 'char[int]' for array subscript
3. compilation terminated due to -Wfatal-errors.

Any advice or ideas?

The function getline:

http://www.cplusplus.com/reference/string/string/getline/

Two parameters. First parameter an input stream. Second parameter a string.

You are trying to use it like this:
getline (cin, opt[i]);

cin is an input stream. Good.
opt[i] is ... I've no idea.

opt is a char. opt[i] makes no sense whatsoever.

If you want to use a function, you have to pass it parameters of the type it expects. getline expects the second parameter to be a string.
Topic archived. No new replies allowed.