Mail Archives: djgpp/1998/03/22/22:02:18
^Hawk^ (Thorsten Kaben) wrote:
>
> On Sat, 21 Mar 1998 17:35:44 -0800 (PST), you wrote:
>
> >First of all, why do you use `__crt0_argv'? You're supposed to use the
> >arguments `main' gets.
> Sorry ... I don't understand all here ... my english ... :( ... if I
> try to use only "_argv[x]" or "argv[x]" then the compiler tould me
> that this is undeclared in spite of including the crt0.h ... if I use
> "__crt0_argv[x]" then it works fine ...
In standard C, you can read the program's command line arguments by
defining main() like so:
/* args.c */
#include <stdio.h>
int main( int argc, char *argv[] )
{
int i;
for ( i = 0; i < argc; i++ )
printf( "Argument %d = %s\n", i, argv[i] );
return 0;
}
[WIN] D:\TEMP>gcc -Wall -o args.exe args.c
[WIN] D:\TEMP>args hello there 38383
Argument 0 = d:/temp/args.exe
Argument 1 = hello
Argument 2 = there
Argument 3 = 38383
Nothing could be simpler.
> >If you really *must* have `\'s (like if your program scans filenames for
> >them), you can #include <crt0.h> and put this line at the top level (i.e.,
> >not inside any function):
> >_crt0_startup_flags = _CRT0_FLAG_USE_DOS_SLASHES;
> >See the libc documentation for "_crt0_startup_flags" for more info.
> Great! Thank you! ;)
I'll rephrase what Nate said: you do not need to use backslashes in
your programs. MS-DOS understands both kinds of slashes. Don't you
think this would have been fixed already if it didn't work?
The only time you would ever need to use backslashes instead of forward
slashes is if you are calling another DOS program from that does not
understand forward slashes.
--
---------------------------------------------------------------------
| John M. Aldrich | "Animals can be driven crazy by pla- |
| aka Fighteer I | cing too many in too small a pen. |
| mailto:fighteer AT cs DOT com | Homo sapiens is the only animal that |
| http://www.cs.com/fighteer | voluntarily does this to himself." |
---------------------------------------------------------------------
- Raw text -