Re: getline and CR, LF, CR/LF, VS/Linux



"Ian Semmel" <isemmel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:O27xtnNhFHA.2916@xxxxxxxxxxxxxxxxxxxxxxx
> What is the correct method for handling text files which may (or may not)
> have a CR character at the end of each line ?
>
> There seems to be a difference the windows/linux VS/gcc handle the
> situation.
>
>
> My program works OK under VS, but in linux it appears to read the first
> line then returns EOF ?

Windows, Mac, and Linux/Unix - all three have different EOL characters. The
STL streams work correctly on all platforms as long as you read the text
files in the format that corresponds to that platform. If you're writing in
one platform format and try reading in another, you are on your own. Either
process EOL yourself, or convert text files, for example, using dos2unix
(unix2dos) utils.

Gene


.



Relevant Pages

  • Re: Using print with format to stdout generates unwanted space
    ... Based on your description of what you want to do, print is probably not the correct method of controlling output format. ... If an object is not a string, it is first converted to a string using the rules for string conversions. ... # unwanted space character being generated at the ...
    (comp.lang.python)
  • Re: different struct sizes
    ... (as a particular platform defines the word "byte") ... When I ported lcc-win32 to a DSP, ... Each character took *one* byte. ... so stdio support isn't ...
    (comp.lang.c)
  • Re: include file rule
    ... except the new-line character and " '. ... inside quotation marks in my source code in #include directives. ... But what if I give you my source to port to some platform where these ... include files and source files when you put them on your file system. ...
    (comp.lang.c.moderated)
  • Re: Storing variable length data in file -- Paging
    ... For this scheme, you do not want to assign ... This discussion leads me to ponder platform independance of the ... is 'character' equivilent to 'byte' (that is, ... Are freadand fwrite() defined in terms of specific numbers ...
    (comp.lang.c)
  • Re: Bolton station
    ... The station has character, and long may it continue to do so! ... That's not the word that comes to mind when waiting for a connection ... I think most of the character disappeared with the ridiculous 80s ... to the bus station but not when you want to get from platform 1 to ...
    (uk.railway)