Can anyone see whats wrong here?

This is a discussion on Can anyone see whats wrong here? within the C++ Programming forums, part of the General Programming Boards category; Code: #ifndef _STREAM_CPP_ #define _STREAM_CPP_ #include <iostream> #include <fstream> using namespace std; void MakeFile(ofstream&, char*); void ReadFile(ifstream&, char*, char*); int ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    18

    Can anyone see whats wrong here?

    Code:
    #ifndef _STREAM_CPP_
    #define _STREAM_CPP_
    
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    void MakeFile(ofstream&, char*);
    void ReadFile(ifstream&, char*, char*);
    
    int main(int argc, char **argv)
    {
     ofstream fout;
     ifstream fin;
     char *Array= new char[50];
    
     MakeFile(fout, "Something.txt");
     ReadFile(fin, "Something.txt", Array);
    
     delete [] Array;
     cin.get();
     return 0;
    }
    
    void MakeFile(ofstream& fout, char* FileName)
    {
     if( (FileName== NULL) || (fout.is_open()) ) { return; }
    
     fout.open(FileName, ios::app);
     fout << "Spiders Are Scary!!" << endl;
     fout.close();
    }
    
    void ReadFile(ifstream& fin, char* FileName, char* Buffer)
    {
     if( (Buffer== NULL) || (fin.is_open()) ) { return; }
     int x= 0;
    
     fin.open(Buffer);
    
     while( !(fin.eof()) || (Buffer[x]!= NULL) )
     {
      fin >> Buffer[x];
      cout << Buffer[x];
    
      x++;
     }
    
     fin.close();
    }
    
    #endif

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    305
    im thinking that you want to input to buffer? dont you have to give it the address? void ReadFile(ifstream&, char*, char&*);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 07-15-2004, 03:30 PM
  2. Debugging-Looking in the wrong places
    By JaWiB in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-03-2003, 09:50 PM
  3. Confused: What is wrong with void??
    By Machewy in forum C++ Programming
    Replies: 19
    Last Post: 04-15-2003, 12:40 PM
  4. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 11:01 AM
  5. Whats wrong?
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 07-14-2002, 01:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21