Date: Mon, 30 Mar 2009 21:13:57 -0600 From: Joshua Gimer <jgimer@gmail.com> To: Gary Kline <kline@thought.org> Cc: FreeBSD Mailing List <freebsd-questions@freebsd.org> Subject: Re: Why?? (prog question) Message-ID: <cf939bff0903302013mdc4f432yacd7109c46341193@mail.gmail.com> In-Reply-To: <20090331025726.GA10888@thought.org> References: <20090331025726.GA10888@thought.org>
next in thread | previous in thread | raw e-mail | index | archive | help
main(int argc, char *argv[]) On Mon, Mar 30, 2009 at 8:57 PM, Gary Kline <kline@thought.org> wrote: > people, i've been under the weather for days and will probably be for a f= ew more. > new =A0and TEMPORARY meds dont like me, ugh. > > can anybody clue me in why the followin joinline program fails to catch i= f argc =3D=3D 1? > > > /* > =A0* simple prog to join all | very nearly all lines of a text file that > =A0* make up one paragraph into one LONG line. > =A0* > =A0* paragraphs are delimiated by a single \n break. > =A0*/ > > #include <stdio.h> > #include <string.h> > #include <stdlib.h> > > main(int argc, char argv[]) > { > =A0 char buf[65536]; > > =A0 if (argc =3D=3D 1) > =A0 { > =A0 =A0 =A0 =A0printf("Usage: %s < file > newfile\n", argv[0]); > =A0 =A0 =A0 =A0exit (-1); > =A0 } > =A0 while (fgets(buf, sizeof buf, stdin) ) > =A0 { > =A0 =A0 if (*buf =3D=3D '\n') > =A0 =A0 { > =A0 =A0 =A0 fprintf(stdout, "\n\n"); > =A0 =A0 } > =A0 =A0 else > =A0 =A0 { > =A0 =A0 =A0 buf[strlen(buf)-1] =3D ' '; > =A0 =A0 =A0 fputs(buf, stdout); > =A0 =A0 } > =A0 } > } > > > -- > =A0Gary Kline =A0kline@thought.org =A0http://www.thought.org =A0Public Se= rvice Unix > =A0 =A0 =A0 =A0http://jottings.thought.org =A0 http://transfinite.thought= .org > =A0 =A0The 2.41a release of Jottings: http://jottings.thought.org/index.p= hp > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.o= rg" > --=20 Thx Joshua Gimer
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?cf939bff0903302013mdc4f432yacd7109c46341193>