I am pretty new to programming. I am writing a fairly small and simple trivia program. It will be my 5th program to date. My biggest problem is how to add a list of Q/A.

The program has 2 functions that handle the trivia part of the game. The 1st is a list of all the questions, answers, and question types. I wrote a small program (shown below) to create that function more me. That will allow me to easily adjust the size of my game at any time.

Now I need a way to add the 3 values of each question to. I have spent most of yesterday and today looking for a way to do this. Please somebody help me. What function do I need to use?

I posted on another forum. I got one responce, told me that get.line() might do what I need. I already know how to read a string. What I need is a way to tell my program what string to read, and where to write it.

I hope I made my problem clear. If there is anything I left out, or made unclear I will be happy to try and clear it up. Please help me. I am at a complete stand still here.

Thank you for taking to time to read this. I do hope you will be able to help

#include <fstream>
#include <iostream>

using namespace std;

int main()
{
  int x;
  int y;
  
  ofstream a_file ( "list.cpp", ios::app );

  a_file<<"void list() \n{\n\nstring word2;\n\n";
  
  for ( x = 0; x < 4;x++ ) {
    for ( y = 0; y < 4; y++ )
 

  a_file<< "    if ((x == " << x << ") && (y ==" << y << "))\n    {"
    << "\n        string word2 = question(,,,); \n    }\n\n";
 
  }
a_file.close();

}

What you are doing is a very aukward and poor design. I think you are approaching this all wrong. why not just use dynamic arrays, such as std::vector, which can contain as many i78tems as you want without resorting to rewriting the function and recompiling the program every time.

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.