Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Programming exercise/challenge Date: Tue, 08 Dec 2020 23:32:20 -0800 Organization: A noiseless patient Spider Lines: 20 Message-ID: <86mtyn5ta3.fsf@linuxsc.com> References: <86wnxwkyol.fsf@linuxsc.com> <86r1o1hxtn.fsf@linuxsc.com> <20201209030320.4dad4f2c624e613bd47fceed@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="5eb73538a536c16dceb299f9d9a18884"; logging-data="24239"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Z/Y/h43//S59ozPR1Mn3oljlXIBgdrf0=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:AAyyPL4wtKqcjIdAFNIo7yIbARE= sha1:8UjQyERvW+Xzyl/jXyenJ201hy8= Xref: csiph.com comp.lang.c:157127 Anton Shepelev writes: > Tim Rentsch: > >> The program is to remove (see below) C comments from a C >> source file input, and nothing else. An input with no C >> comments in it should be transmitted unchanged (provided >> its compile-time behavior is defined, see below). To give >> an obvious example, a multi-line macro definition that >> uses at the end of lines to continue the definition (but >> has no comments) should appear in the output exactly as in >> the input. > > Are you certain that the requirement to keep escape line > endings in the code is satisifiable within O(1) memory > requirements? [...] Strictly speaking I think it is O( log n ) memory, but in practical terms a single counter should suffice, like in Richard Damon's explanation.