Path: csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: why additional \r before each \r\n Date: Mon, 06 Mar 2023 10:00:53 -0800 Organization: None to speak of Lines: 29 Message-ID: <87ttyxlpyi.fsf@nosuchdomain.example.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader01.eternal-september.org; posting-host="5c1233dfadea1cd64002867ff687e744"; logging-data="19656"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lUzZHKJHJMGOJzXEEr1Ib" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:fn+ifp97p2hJ4pgGaBMB6XR7qi8= sha1:KM8mpWZ8CmMmC12CgVy9UTjM8ls= Xref: csiph.com comp.lang.c++:89488 Jivanmukta writes: > W dniu 06.03.2023 o 17:14, Bo Persson pisze: >> 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). >> > I changed definition of END_LINE: > > #define END_LINE "\n" > > and it solved the problem. > Thank you for help. I suggest it would be clearer to drop the END_LINE macro and use "\n" or '\n' directly. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for XCOM Labs void Void(void) { Void(); } /* The recursive call of the void */