M
Merrill & Michele
What follows is an adaptation of the second program in K&R §5.10. The
changes are to elucidate (validate) the difference (sameness) of char *[]
and char**. I cannot for the life of me understand why the output looks the
way it does, in particular, with all the symmetry in arguments, why one sees
apple[0] but not argv[0]. This program was designed to run from a command
line with one argument (two if you count the prog name). The .c file
follows. Afterwards I post a link to a screenshot of output.
#include <stdio.h>
int main(int argc, char **argv)
{
char **apple;
apple[0]="tja zero";
apple[1]="tja again";
while (--argc >0)
printf("%s%s", *++argv, (argc > 1) ? " " : "");
printf("\n");
printf("%s%s", *++apple, (argc > 1) ? " " : "");
printf("\n");
return (0);
}
http://home.comcast.net/~beckjensen/cstuff3.htm
++thanks. MPJ
changes are to elucidate (validate) the difference (sameness) of char *[]
and char**. I cannot for the life of me understand why the output looks the
way it does, in particular, with all the symmetry in arguments, why one sees
apple[0] but not argv[0]. This program was designed to run from a command
line with one argument (two if you count the prog name). The .c file
follows. Afterwards I post a link to a screenshot of output.
#include <stdio.h>
int main(int argc, char **argv)
{
char **apple;
apple[0]="tja zero";
apple[1]="tja again";
while (--argc >0)
printf("%s%s", *++argv, (argc > 1) ? " " : "");
printf("\n");
printf("%s%s", *++apple, (argc > 1) ? " " : "");
printf("\n");
return (0);
}
http://home.comcast.net/~beckjensen/cstuff3.htm
++thanks. MPJ