Mail Archives: djgpp/2000/06/09/00:47:39
On Wed, 7 Jun 2000, Marcelo Juchem wrote:
> I'm having some problems when using the special parameters for main().
> Please, could you tell-me what am I doing wrong?
> Thank you!
> Marcelo Juchem, mj-me AT plug-in DOT com DOT br
>
> THE RESULTS AND SOURCE-CODE FOLLOW:
>
> ---------------------------------------------------------------------------
> With the following command-line: gpp -o cmdline.exe cmdline.cpp
> The results are:
> ---------------------------------------------------------------------------
> cmdline.cpp: In function `int main(int, char **)':
> cmdline.cpp:11: invalid types `int[int]' for array subscript
>
> ---------------------------------------------------------------------------
> With the following command-line: gpp -O3 -o cmdline.exe cmdline.cpp
> The results are:
> ---------------------------------------------------------------------------
> cmdline.cpp: In function `int main(int, char **)':
> cmdline.cpp:11: invalid types `int[int]' for array subscript
>
> ---------------------------------------------------------------------------
> The following source code:
> ---------------------------------------------------------------------------
> #include <stdio.h>
> #include <conio.h>
>
> void waitkbd(void);
>
> int main(int argc,char **argv)
> {
> int c;
> printf("\n ");
> for(c=1;c<argc-1;c++)
> printf("%s ",argc[c]);
^^^^
this should be argv, not argc,
argc is an integer, not an integer array.
%s in the printf-command is expecting a pointer to a string, just that
what argv(c) is--an array of pointers to strings.
sorry the () should be brackets, im just fighting with some keyboard setup
thingies ;)
> waitkbd();
> return(0);
> }
>
> void waitkbd(void)
> {
> while(kbhit()) getch();
> getch();
> }
>
- Raw text -