Felipe Valdez <[EMAIL PROTECTED]> wrote:
>
> windows : \r\n
> mac:       \r
> linux  \n

No. \r and \n are implementation defined character constants. Even on
ascii systems, there is no guarantee that \n is 10 and \r is 13 [see
early macintosh systems.]

You should state line formats in actual terms, e.g. ascii...

  Windows/DOS: text<cr><lf>
  Mac (old):   text<cr>
  Mac (new):   text<lf>
  *nix:        text<lf>

...or...

  HTML:        <RS>text<RE>

Because there are so many different end of line conventions, how a
given text file stores lines on a given system is made transparent
under C (and C++). If you open a stream as a text stream, then the
local end of line is converted to and from a single '\n'.

Compilications arise when text files are transfered between systems
without appropriate translation. This isn't something that C and C++
(nor indeed any other language) can deal with automatically.

Many text parsers generally don't care about end of line markers, so
simply skipping whitespace is sufficient.

For more complicated parsers, I have my own 'getline' routine which
strips out \r and \n but treats \r[\n] and \n\[r] as an end of line.
It's a simple exercise for a programming student.

--
Peter





To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.


Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=298184.5639630.6699735.3001176/D=groups/S=:HM/A=2434971/rand=995425155


Yahoo! Groups Links

Reply via email to