Mail Archives: djgpp/2010/01/04/20:15:05
"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 -