Thread: How to get rid of newline character

  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,366
    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,663
    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, 09:29 PM
  2. LoadFromFile() from a txt
    By Snoopy104 in forum C++ Programming
    Replies: 6
    Last Post: 03-14-2006, 10:05 AM
  3. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10: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, 07:23 PM