delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2010/01/04/20:15:05

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Rod Pemberton" <do_not_have AT nohavenot DOT cmm>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: gcc ching.c compile failed
Date: Mon, 4 Jan 2010 20:02:44 -0500
Organization: Aioe.org NNTP Server
Lines: 88
Message-ID: <hhu35h$c24$1@speranza.aioe.org>
References: <alpine DOT BSF DOT 2 DOT 00 DOT 1001031620510 DOT 77719 AT freire1 DOT furyyjbeyq DOT arg>
NNTP-Posting-Host: pldq+kT97bAAp/ObDwnZyQ.user.speranza.aioe.org
X-Complaints-To: abuse AT aioe DOT org
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1983
X-Notice: Filtered by postfilter v. 0.8.1
X-Newsreader: Microsoft Outlook Express 6.00.2800.1983
Cancel-Lock: sha1:1fDPooiq+nnn/5rkX1aLoRL0NdI=
X-Priority: 3
X-MSMail-Priority: Normal
Bytes: 3229
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Jude DaShiell" <jdashiel AT shellworld DOT net> wrote in message
news:alpine DOT BSF DOT 2 DOT 00 DOT 1001031620510 DOT 77719 AT freire1 DOT furyyjbeyq DOT arg...
> This program compiles correctly with gcc.  gcc ching.c -o ching <cr>.
> The only output this program generates is the useage message.  I have
> ching.txt located in /usr/local/lib/ching.txt.  What has me puzzled is why
> no other output is available.  Is this a program that needs a different
> compiler?  I can build it with Power C if need be but if such a build
> produces more output, what is the difference that makes gcc work in this
> way?
>

Let's reformat main():

> int main(int argc, char *argv[])
> {
>   int i;
>   char hexagram[6];
>
>   if (argc == 1) {
>   cast(hexagram);
>   i = 6;
>   }
>   else for (i = 0; i < 6 && argv[1][i] >= '6' && argv[1][i] <= '9'; i++)
hexagram[i] = argv[1][i];
>   if (argc > 2 || i < 6) {
>   fprintf(stderr, "usage: %s [hexagram]\n", argv[0]);
>   exit(1);
>   }
>   print(hexagram);
>   if (changing(hexagram)) {
>   fputs("\n", stdout);
>   change(hexagram);
>   print(hexagram);
>   }
>   return 0;
> }

int main(int argc, char *argv[])
{
  int i;
  char hexagram[6];

  if (argc == 1)
  {
    cast(hexagram);
    i = 6;
  }
  else
  {
    for (i = 0; i < 6 && argv[1][i] >= '6' && argv[1][i] <= '9'; i++)
    {
      hexagram[i] = argv[1][i];
    }
  }

  if (argc > 2 || i < 6)
  {
    fprintf(stderr, "usage: %s [hexagram]\n", argv[0]);
    exit(1);
  }

  print(hexagram);
  if (changing(hexagram))
  {
    fputs("\n", stdout);
    change(hexagram);
    print(hexagram);
  }
  return 0;
}


It appears to me that the program must be called with no arguments or one
special argument.  The special argument must be a six digit number with
values for each digit from 6 to 9.  e.g, 777777 or 697886.  If a digit isn't
from 6 to 9, then the "i" value will be less than 6, so the usage message is
displayed.  Notice that's not "argc < 6", but "i < 6".  When six valid
digits are entered, the program attempts to open the path - which doesn't
exist on my system.  Without an argument, it expects some characters from
the keyboard, followed by a return, followed by an EOF (ctrl-Z for DOS).
Then it goes on to attempt to open the path.

Did that help?


Rod Pemberton


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019