Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   i/o strems using 2 dimensional array (http://www.go4expert.com/forums/i-o-strems-using-2-dimensional-array-t16862/)

natasha23 10Apr2009 12:16

i/o strems using 2 dimensional array
 
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


All times are GMT +5.5. The time now is 05:49.