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

  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, 12:41 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02: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, 10:25 PM