C problems

porges at inmet.UUCP porges at inmet.UUCP
Sat Jun 3 02:20:00 AEST 1989


>/* Written  3:34 am  May 30, 1989 by deven at rpi.edu.UUCP in inmet:comp.lang.c */
   #include <stdio.h>
   main(argc, argv)
   {
   [...]

>This error has nothing to do with the I/O; you never declared what the
>parameters rto main were, so the compiler assumed integer for both.
>argc is an integer, but argv is a char **.  You need to add a line
>after main(argc,argv) but BEFORE the "{" which reads "char **argv;" or
>"char *argv[];" (take your pick; they mean the same.) and you *should*
>add right before it "int argc;" but you don't need to, since the
>compiler will assume it.
>

    Since noone else jumped in on this:  char **argv and char *argv[] are NOT
the same thing in delcarations.  In the first case you have a pointer to
a pointer to a character; you may in fact have a pointer to an array of
pointer to characters.  In the second case, however, you have an array
of unknown size of character pointers on the argument stack.  You
almost certainly want char *argv[].

					-- Don Porges
					porges at inmet.com
					{...mirror,ima}!inmet!porges



More information about the Comp.lang.c mailing list