Thread: file i/o
View Single Post
  #1 (permalink)  
Old 09-14-2008, 06:03 PM
erabyss erabyss is offline
Newbie
 
Join Date: Sep 2008
Posts: 6
Credits: 0
Rep Power: 0
erabyss is on a distinguished road
Default file i/o

I am writing a "labyrinth" style game. Minus the maze, because lack of graphic abilties. I used an array to mark the dimensions of the room. and with every step, I force the player to solve a problem.

I wrote the program below to write the "list" function for me. All that is left is to add the questions and answers. I need a program that can read from "file_A", which has a list from all my Q&A, and write to "file_B".

I know how to read from a file. But not how to copy specific lines of text. Do you know where I can find to code that will allow me to do that?

Thank you for your help. I cant wait to have this game finished.

Code:
#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();

}
Reply With Quote

Sponsored Links