Ok, so as suggested I have rewritten this thread.

It was suggested that the code posted to be shortened and only revelent code be posted. I did both of these and people started asking where all different things were, and why cant they see other files etc.

Uploaded is the full code to the revelent part, and compiling this will give you a stripped down version of a MUCH bigger program.

The code is compiled in Codeblocks.

The problem is with this part of the code:

RiddleGenerator::QnA RiddleGenerator::mQnA[RiddleGenerator::QuestionCount] = {
        { "What shape as 4 sides?\n\t1)Triangle\n\t2)Circle\n\t3)Square", 3 },
        { "What is the capital of England?\n\t1)Paris\n\t2)London\n\t3)Washington", 2 }

        // NEW QUESTIONs CAN GO IN THE ABOVE SPACE <---!
};

which is in Question_Math_Riddle_Generator.h line 166.

The main game loop is at the bottem of main.cpp as the top is all the connections between the rooms.

The question is:

Can the questions shown above be loaded from a text file and continue to function correctly. The purpose of this is so the person this application is given to, can edit the questions without having to have the source code.

The purpose of Question_Math_Riddle_Generator.h is to create random questions both riddle and math when called. Each time the user moves to a new room a question is called.

I know the problem is aorund the I/O ffstream area, I just DON'T KNOW how to adapt it for a struct.

Sorry I missed two files.

well if you want to store questions in a text file where the user can change them the i would suggest just writing a simple output protocol where it is outputted line by line like:

What shape as 4 sides?
1)Triangle
2)Circle
3)Square
3
make this line a blank line
start the next question here

then you could read the file line by line and put your formatting of the string in when you read it from the file. i believe this would very easy for a user to change the questions and answers. hopefully this makes sense.

Thank you Nathan :) That is very helpful, I hope this works for my structure :)

well if you want to store questions in a text file where the user can change them the i would suggest just writing a simple output protocol where it is outputted line by line like:

What shape as 4 sides?
1)Triangle
2)Circle
3)Square
3
make this line a blank line
start the next question here

then you could read the file line by line and put your formatting of the string in when you read it from the file. i believe this would very easy for a user to change the questions and answers. hopefully this makes sense.

sorry about the double post i had browser problems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.