Thread: Writing to a file and skipping line

  1. #1
    The Negativity. LAURENT*'s Avatar
    Join Date
    May 2012

    Writing to a file and skipping line

    I know how to skip lines whiles reading from a file but I don't know how to skip during the writing. Can lines in a file be skipped while writing to them or would I need to rewrite exactly what I need in one go?
    UPDATE! As of 10/6/2014
    Just find the application file and double click it. Controls are (Arrow keys) (Z) (Z + arrow key) (Spacebar)
    Don't play this crappy update. Wait for the newest one which is far more impressive.

    Official Sonic character poll hosted by some guy at Sega..... Sega of America. Vote for blaze because she OP.

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    United States
    They won't be skipped so much as you decide not to write them somehow.

    This will print strings that are only decimal numbers, for example:
    for (string& elem : container) {
       std::string::iterator it = std::find_if(elem.begin(), elem.end(), [](char ch) { return !std::isdigit(ch); } );
       if (it == elem.end())

  3. #3
    Registered User
    Join Date
    Nov 2013
    The only way you could do that is if you were writing to the file line by line, then you could check to see if any line contained no data and skip if so. If you are dumping a chuck of data to a file, you would need to reopen the file and parse through line by line to remove any empty lines, save the result and write back to the file again..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Skipping to a new line in an input file.
    By earth_angel in forum C Programming
    Replies: 15
    Last Post: 06-14-2005, 01:25 PM
  2. writing new line at end of file
    By deleeuw in forum C++ Programming
    Replies: 4
    Last Post: 09-23-2003, 10:23 PM
  3. Skipping 2 next line when reading in from file?
    By aspand in forum C++ Programming
    Replies: 4
    Last Post: 03-21-2003, 10:22 AM
  4. why is this writing the last line twice to the file
    By Shadow12345 in forum C++ Programming
    Replies: 1
    Last Post: 12-09-2002, 02:37 AM
  5. Skipping the rest of the line while doing file input
    By Shadow12345 in forum C++ Programming
    Replies: 2
    Last Post: 09-30-2002, 09:25 AM