www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/22/22:02:18

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Debug and "/" with RHIDE / WIN95 / DJGPP
Date: Sun, 22 Mar 1998 18:59:49 -0500
Organization: Two pounds of chaos and a pinch of salt.
Lines: 57
Message-ID: <3515A5F5.717E@cs.com>
References: <199803220135 DOT RAA16691 AT adit DOT ap DOT net> <3516730f DOT 4123801 AT mail DOT on-luebeck DOT de>
NNTP-Posting-Host: ppp202.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

^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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019