Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Question about C

Reply
Thread Tools

Question about C

 
 
Richard Bos
Guest
Posts: n/a
 
      05-17-2010
Malcolm McLean <(E-Mail Removed)> wrote:

> On May 12, 6:06=A0am, (E-Mail Removed) wrote:
> >
> > No, argv[0] contains the *name* of the program, which is usually *not*
> > the complete path and might not have anything whatsoever to do with the
> > path to the executable file.


Not even that; it _represents_ the program name. If the program has been
called in an unusual way (or on an unusual OS), it might not even have
anything to do with the real name of the executable file.

> You need to look at the environment pointer, passed in as a third
> parameter, which usually contains the paths to directories containing
> executables. However that's also non-ANSI, of course.


....and, partly because of the above, does not work in the general case.

And then, even with a perfectly normal program execution, who is to say
that running "\not\in\the\normal\executable\PATH\environment\pr ogname"
does not result in argv[0] containing only "progname"? If PATH contains
"\$HOME$\programs;\public\programs;\\progserver\\p ublic\programs" and
there happens to be another program, also called "progname", on that
server referred to in that PATH, your method will find the wrong program
file. And that's not a _very_ unlikely scenario, you'll have to admit.

Richard
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments