Why?? (prog question)

Joshua Gimer jgimer at gmail.com
Mon Mar 30 20:40:00 PDT 2009


main(int argc, char *argv[])

On Mon, Mar 30, 2009 at 8:57 PM, Gary Kline <kline at thought.org> wrote:
> people, i've been under the weather for days and will probably be for a few more.
> new  and TEMPORARY meds dont like me, ugh.
>
> can anybody clue me in why the followin joinline program fails to catch if argc == 1?
>
>
> /*
>  * simple prog to join all | very nearly all lines of a text file that
>  * make up one paragraph into one LONG line.
>  *
>  * paragraphs are delimiated by a single \n break.
>  */
>
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>
>
> main(int argc, char argv[])
> {
>   char buf[65536];
>
>   if (argc == 1)
>   {
>        printf("Usage: %s < file > newfile\n", argv[0]);
>        exit (-1);
>   }
>   while (fgets(buf, sizeof buf, stdin) )
>   {
>     if (*buf == '\n')
>     {
>       fprintf(stdout, "\n\n");
>     }
>     else
>     {
>       buf[strlen(buf)-1] = ' ';
>       fputs(buf, stdout);
>     }
>   }
> }
>
>
> --
>  Gary Kline  kline at thought.org  http://www.thought.org  Public Service Unix
>        http://jottings.thought.org   http://transfinite.thought.org
>    The 2.41a release of Jottings: http://jottings.thought.org/index.php
>
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
>



-- 
Thx
Joshua Gimer


More information about the freebsd-questions mailing list