Home  |   Notes  |   Languages  |   Programs  |   Homework

Re: Newline characters

New Message Reply About this list Date view Thread view Subject view Author view

Stephen Edwards (edwards@CS.VT.EDU)
Thu, 27 Sep 2001 20:37:23 -0400


Message-ID:  <3BB3C643.CE3E4A63@cs.vt.edu>
Date:         Thu, 27 Sep 2001 20:37:23 -0400
From: Stephen Edwards <edwards@CS.VT.EDU>
Subject:      Re: Newline characters

> I know there are a couple ways to test for the end of line

The preferred method is to call the boolean function Eoln to
detect newlines and to use readln to read in/skip over them.

> for some reason
> I will read in a newline character one time and my program will
> say it is an invalid token and then the next
> time it will recongize it as an end of expression token.

Remember that on PCs, a "new line" in a text file is represented
by a two-character sequence: a carriage return character (CR)
followed by a line feed character (LF). If you are reading one
character at a time, it will take two reads to process this
CR-LF pair. My guess is that you are only recognizing one of
the two characters as an end-of-expression token (probably the
linefeed).

                                -- Steve

--
Stephen Edwards            604 McBryde Hall          Dept. of Computer Science
e-mail      : edwards@cs.vt.edu           U.S. mail: Virginia Tech (VPI&SU)
office phone: (540)-231-5723                         Blacksburg, VA  24061-0106
-------------------------------------------------------------------------------


New Message Reply About this list Date view Thread view Subject view Author view

Home  |   Notes  |   Languages  |   Programs  |   Homework
copyright © 2001 Virginia Tech, ALL RIGHTS RESERVED
Class site maintained by Stephen H. Edwards <edwards@cs.vt.edu>