output file streams

This is a discussion on output file streams within the C++ Programming forums, part of the General Programming Boards category; i wrote this program, but it doesn't work. it keeps giving me the error "test_file not recognized". i have a ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    8

    output file streams

    i wrote this program, but it doesn't work. it keeps giving me the error "test_file not recognized". i have a floppy disk in my computer when i run this program. i thought that if there is no file by the name that you specify (in this case test_file), the computer makes one. this didn't happen, so i made a blank file called "test file" on my floppy disk, but even then, it didn't work.
    check it out.....

    #include <iostream.h>
    #include <conio.h>
    #include <fstream.h>
    #include <assert.h>
    #include <STDIO.h>

    //LEVEL ONE FUNCTION PROTOTYPES///////////////////////////////////////////
    void SaveToDisk(ofstream &neil);


    int main()
    {
    clrscr();
    ofstream neil;

    SaveToDisk(neil);

    neil.close();

    getch();
    return 0;
    }

    void SaveToDisk(ofstream &neil)
    {
    neil.open(test_file.c_str());
    assert(! neil.fail());
    neil<<1234<<endl;
    }

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    you haven't declared a test_file variable. if you just want a file called test_file to open:

    Code:
    neil.open("test_file.txt");

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 01:13 AM
  2. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 08:01 PM
  3. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 11:12 PM
  4. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM
  5. Simple File Creation Algorithm
    By muffin in forum C Programming
    Replies: 13
    Last Post: 08-24-2001, 04:28 PM

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