Need some insight on detecting a new line character using data type ch

Using char data type to determine if a new line char is read in from a

Page 1 of 1

1 Replies - 1690 Views - Last Post: 27 November 2008 - 05:49 AM Rate Topic: -----

#1 haynest  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 09-November 08

Need some insight on detecting a new line character using data type ch

Post icon  Posted 27 November 2008 - 04:18 AM

Hello all!
I have been picking my brain and googling on this issue. I think there is an easy way to do this or some simple logic but I'm still a n00b and am having some issues. Anyway... I am trying to think of a way to detect a new line character while reading in character by character from a file. I don't think a char data type can read the new line character. But I need it to or maybe I can convert the input somehow? I am pretty much up for almost anything at this point :crazy:

Thanks in advance guys!

char inputTemp;

while(inputTemp != '\n')
  {
   //do some stuff

   cin >> inputTemp;
   }



Is This A Good Question/Topic? 0
  • +

Replies To: Need some insight on detecting a new line character using data type ch

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 991
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Need some insight on detecting a new line character using data type ch

Posted 27 November 2008 - 05:49 AM

Depending on what system you expect the code to run on couldn't you just test for the ASCII value for CR, CRLF, LF (as appropriate)?

http://www.december....spec/ascii.html
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1