Thread: Simple Problem

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    2

    Simple Problem

    I'm trying to learn about file i/o but I can't get this program to work.

    Code:
    #include <fstream>
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
      char a_char;
      ofstream a_file ( "log.txt" );
      a_char = getchar();
      cout << a_char;
      a_file << a_char;
      a_file << "This text will now be inside of log.txt";
      a_file.close();
    }
    For some reason, the entered string is not going into the file.

    Any help is appreciated!

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    2

    Sorry

    I'm sorry, I just figured it out right after I posted.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A simple file I/O problem
    By eecoder in forum C Programming
    Replies: 10
    Last Post: 10-16-2010, 11:00 PM
  2. Problem in simple code.
    By richdb in forum C Programming
    Replies: 6
    Last Post: 03-20-2006, 02:45 AM
  3. Problem in very simple code
    By richdb in forum C Programming
    Replies: 22
    Last Post: 01-14-2006, 09:10 PM
  4. Simple Initialization Problem
    By PsyK in forum C++ Programming
    Replies: 7
    Last Post: 04-30-2004, 07:37 PM
  5. Simple OO Problem
    By bstempi in forum C++ Programming
    Replies: 1
    Last Post: 04-30-2004, 05:33 PM