formating file output

This is a discussion on formating file output within the C++ Programming forums, part of the General Programming Boards category; how would I output to a file two variables but one on each line I have done this but it ...

  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
    31173 h4x0r gnu-ehacks's Avatar
    Join Date
    Nov 2001
    Posts
    556
    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, 02:11 AM
  2. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 11:12 PM
  3. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 05: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, 04:28 PM

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