Path: csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Fri, 19 May 2017 12:51:02 -0500 From: Gareth Owen Newsgroups: comp.lang.c Subject: Re: Some ideas about c? References: <87bmqp7utb.fsf@gmail.com> Date: Fri, 19 May 2017 18:51:02 +0100 Message-ID: <8737c0ybuh.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:tzzJlS7XJ7jLuqrM9gibASC/0aU= MIME-Version: 1.0 Content-Type: text/plain Lines: 28 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-VVaSXEgTmPJBzkcsRTlFw2woW7GG4fvOBVLd0g/l/Qgi0OMlOyLW8ARG3dw74tdwdf0rBD/MKNhPjmZ!r/APmGObUk4mFkhK1F/zMTyPs89q7HwHaST2ZQuMr4zX+BBZhH7WKDO1SEU92w1yP4HCV+Y= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2134 Xref: csiph.com comp.lang.c:110399 scott@slp53.sl.home (Scott Lurndal) writes: > Gareth Owen writes: >>scott@slp53.sl.home (Scott Lurndal) writes: >> >>> int main() { char buffer[512]; fputs(fgets(buffer, sizeof(buffer), >>> stdin), stdout); } >> >>Great. Except it doesn't work if the input line is too big. > > Sure it does. It just truncates it. And the programmer is, of > course, aware of that. If I want a program to duplicate the line, and sometimes it truncates it then that program does not work correctly. For every programming problem there is a solution that is short, elegant and wrong. >> >>> For that matter, this code also compiles just fine as C++ code. >> >>But doesn't run fine as either. I assume, you knew that. > > Actually, it does compile and run using the C++ compiler. Except that sometimes it does not duplicate the output correctly. The program has a bug in it - to whit whenever an input line is longer than 512 bytes, the output is incorrect.