Is there any built in way to write a new line using fwrite

This is a discussion on Is there any built in way to write a new line using fwrite within the C++ Programming forums, part of the General Programming Boards category; in order to write a new line, I am currently doing the following: char NewLine[] = "\n"; and whenever I ...

  1. #1
    Shadow12345
    Guest

    Is there any built in way to write a new line using fwrite

    in order to write a new line, I am currently doing the following:
    char NewLine[] = "\n";

    and whenever I want a new line I call:
    fwrite(NewLine, 1, sizeof(char), output);

    Is there any built in way of writing newlines so I can stop this lame ass method? Well I guess it isn't lame ass, i'm just bored so im asking stupid questions.

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I'm board too. So I'll give you a fun answer.

    Code:
    #include <cstdlib>
    
    using std::rand;
    
    void newline(FILE *file) {
         bool DidOutput = false;
         int i;
    
         for(;!DidOutput;) {
              i = rand();
              if(!i) {
                   DidOutput = true;
                   fputc(012, file);
              }
         }
    }
    [edit]
    stupid smilies
    [/edit]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help again with scrolling without wrapping
    By Dukefrukem in forum C Programming
    Replies: 8
    Last Post: 09-21-2007, 12:48 PM
  2. Simple question (for you not for me!)
    By antonis in forum C Programming
    Replies: 35
    Last Post: 11-10-2005, 11:41 AM
  3. Replies: 3
    Last Post: 03-04-2005, 01:46 PM
  4. Trouble replacing line of file
    By Rpog in forum C Programming
    Replies: 4
    Last Post: 04-19-2004, 10:22 AM
  5. Some humour...
    By Stan100 in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-06-2003, 09:25 PM

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