Thread: formating file output

  1. #1
    Unregistered
    Guest

    formating file output

    how would I output to a file two variables but one on each line I have done this but it puts one right beside the other...
    Code:
     char hi;
     char bye;
     hi = 'h';
     bye = 'b';
     ofstream file("file.txt");
     file<<hi;
     file<<" ";
     file<<bye;
     file.close();

  2. #2
    Instead of

    file << hi;
    file << " ";
    file << bye;

    Do this:

    file << hi;
    file << '\n'
    file << bye;

    It should work now I hope.
    What will people say if they hear that I'm a Jesus freak?
    What will people do if they find that it's true?
    I don't really care if they label me a Jesus freak, there is no disguising the truth!

    Jesus Freak, D.C. Talk

    -gnu-ehacks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Base converter libary
    By cdonlan in forum C++ Programming
    Replies: 22
    Last Post: 05-15-2005, 01:11 AM
  2. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM
  3. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 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, 03:28 PM