delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/02/23:54:08

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Determining the path of the executable at runtime
Date: Tue, 02 Sep 1997 18:08:26 -0400
Organization: Cornell University http://www.cornell.edu
Lines: 21
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <340C8E59.C8A019DF@cornell.edu>
References: <927cd$11e31 DOT 3dd AT news DOT eznet DOT net>
Reply-To: asu1 AT cornell DOT edu
NNTP-Posting-Host: cu-dialup-0019.cit.cornell.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Karl Garrison wrote:

> Does anyone know how I can find out what directory a program was invoked
> from?  I would perfer an ANSI-C method, but, failing that, a
> DJGPP-specific method would be acceptable.  Specifically:

  compile and run the following program:

#include <stdio.h>

int main(int argc, char* argv[])
{
  printf("%s\n", argv[0]);
  return 0;
}

i do not know how ansi it is to return the full path in addition to the name
of the executable.

  -- Sinan

- Raw text -


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