Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #89483

Re: why additional \r before each \r\n

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Bo Persson <bo@bo-persson.se>
Newsgroups comp.lang.c++
Subject Re: why additional \r before each \r\n
Date Mon, 6 Mar 2023 17:17:42 +0100
Lines 20
Message-ID <k6mi16FavanU2@mid.individual.net> (permalink)
References <tu532n$33e16$1@portraits.wsisiz.edu.pl> <k6mhs0FavanU1@mid.individual.net>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net QlRFJ/WzcucHpgiz26/IfwdL1M9SGuEvmPZgDx61Z+CesX/7X7
Cancel-Lock sha1:CK/p1io2KihLdFb07S6PXJs5vJo=
User-Agent Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0
Content-Language sv
In-Reply-To <k6mhs0FavanU1@mid.individual.net>
Xref csiph.com comp.lang.c++:89483

Show key headers only | View raw


On 2023-03-06 at 17:14, Bo Persson wrote:
> On 2023-03-06 at 17:06, Jivanmukta wrote:
>> Please explain me why this code outputs text with \r\r\n, not \r\n. I 
>> run it in Windows 10. When I call my program with >__test.txt I see 
>> \r\r\n in file __text.txt.
>> I don't know why additional \r in text outputed from get_help() - I 
>> have single END_LINE after each line (in returned string).
>>
>> #define END_LINE "\r\n"
>>
> 
> On Windows (and unlike Linux) the code "\n" is expanded into two 
> characters (Carriage Return and NewLine). This is the way it has been 
> since always (since mechanical printers and such were used).
> 

Also, this is the reason for C and C++ files having text mode and binary 
mode. In binary mode there is no translation.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

why additional \r before each \r\n Jivanmukta <jivanmukta@poczta.onet.pl> - 2023-03-06 17:06 +0100
  Re: why additional \r before each \r\n Bo Persson <bo@bo-persson.se> - 2023-03-06 17:14 +0100
    Re: why additional \r before each \r\n Bo Persson <bo@bo-persson.se> - 2023-03-06 17:17 +0100
    Re: why additional \r before each \r\n Jivanmukta <jivanmukta@poczta.onet.pl> - 2023-03-06 18:55 +0100
      Re: why additional \r before each \r\n Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-06 10:00 -0800
        Re: why additional \r before each \r\n Jivanmukta <jivanmukta@poczta.onet.pl> - 2023-03-06 19:35 +0100
          Re: why additional \r before each \r\n Paavo Helde <eesnimi@osa.pri.ee> - 2023-03-07 08:34 +0200
            Re: why additional \r before each \r\n Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-07 12:17 -0800
  Re: why additional \r before each \r\n Jivanmukta <jivanmukta@poczta.onet.pl> - 2023-03-06 17:24 +0100
  Re: why additional \r before each \r\n James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-03-06 14:30 -0500

csiph-web