Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.lightlink.com!news.iecc.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 19 Oct 2011 23:36:08 -0500 Message-ID: <4E9FA537.54F6@mindspring.com> Date: Thu, 20 Oct 2011 00:36:07 -0400 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: Analogue of ReadLine() in C References: <91b648bd-bf1e-4093-97a4-77b7300a94c5@c1g2000vbw.googlegroups.com> <4E9F570F.5A16@mindspring.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 37 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.223.186 X-Trace: sv3-vcdXeZfESOJEgj1nvfo1fM6NXjLyyom46uVWFmArraI2nPB14VtjxFd/POzBBZnomPVSt8jBHs91+ZH!yBRllGgCaWihwTvoHUF9wk0UaM4mk5uuGh9Lsz+mohqaIQ20vKQpLQy9I6anRr2dhHSc1UGBI5TB!c/kC8MO1Ugw= 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: 1700 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:11897 pete wrote: > void > loop(void) > { > int rc; > char *command = NULL; > size_t n = 0; > > do { > printf("Enter> "); > rc = read_line(&command, &n, stdin, NULL); > } while (rc > -1 && strcmp(command, "exit")); > free(command); > } /* ** Instead, that should be: */ void loop(void) { int rc; char *command = NULL; size_t n = 0; do { printf("Enter> "); fflush(stdout); rc = read_line(&command, &n, stdin, NULL); } while (rc > 0 && strcmp(command, "exit")); free(command); } -- pete