How to get rid of newline character

This is a discussion on How to get rid of newline character within the C++ Programming forums, part of the General Programming Boards category; Does anyone know how to get rid of a newline character? I am reading in from a file and there ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    13

    Question How to get rid of newline character

    Does anyone know how to get rid of a newline character? I am reading in from a file and there is a newline character attached to one of my strings that i dont want. Thank you.

    Angel

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,319
    It depends. Is the newline in the stream and you want to ignore it on a subsequent read? Use ignore(). Is the newline in a C++ string? You can use find and erase, or remove. Is the newline in a C style string? Then maybe somebody else can help.

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    I am reading in from a file and there is a newline character attached to one of my strings
    That's unlikely. How are you reading from the file? What function are you using to read?

  4. #4
    Registered User
    Join Date
    Feb 2006
    Posts
    13
    I used the ignore and it work thank you both very much for helping

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking to see if a string is just a newline character
    By Beowolf in forum C++ Programming
    Replies: 3
    Last Post: 11-14-2007, 08:29 PM
  2. LoadFromFile() from a txt
    By Snoopy104 in forum C++ Programming
    Replies: 6
    Last Post: 03-14-2006, 09:05 AM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 09:46 AM
  4. Any help would be appreciated.....
    By SprinterSteve in forum C Programming
    Replies: 6
    Last Post: 05-01-2003, 09:25 AM
  5. mygets
    By Dave_Sinkula in forum C Programming
    Replies: 6
    Last Post: 03-23-2003, 06:23 PM

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