1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

i/o strems using 2 dimensional array

Discussion in 'C++' started by natasha23, Apr 10, 2009.

  1. natasha23

    natasha23 New Member

    Joined:
    Apr 10, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hay guys i am having a bit of trouble trying to code a two dimensional array that will respond to functions in a class when called from a main program.

    i am reading in a file and i would like to display that file using a two dimensional array

    although the code i have at the moment is creating a file for output but with nothing in it.

    here is my code below:
    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <cstdlib>
    using std::ifstream;
    using std::ofstream;
    using std::endl;
    using std::cout;
    
    using namespace std;
    
    class auditorium
    {
          private:
                  seats [14][30];
          public:
                 void readSeatsConfig();
                 void displaySeatsConfig();
                 void getSeatClass();
                 };
                 
    void auditorium::readSeatsConfig(){
         ifstream infile;
        ofstream outfile;
        
        infile.open("seatsConfig.txt");
        
        if (infile.fail())
        {
           cout <<"file does not exist"<<endl;
           }
        else{
             cout<<"Reading text file"<<endl;
             }
        
        
        infile.close();
    }; 
     
     
    void auditorium::displaySeatsConfig(char s[][30], int sizedimension1){
         ofstream outfile;
         
         for (int i1=0; i1 < sizedimension1; i1++){
             for (int i2; i2 < 30; i2++)
             {
                 outfile << s[i1][i2]<<endl;
                 }
                 }
             outfile.close();
             };
         
    if you could help that would be great

    thanks in advance
     
    Last edited by a moderator: Apr 10, 2009

Share This Page