Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Bo Persson 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: References: 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: Xref: csiph.com comp.lang.c++:89483 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.