Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c    |    Meh, in C you gotta define EVERYTHING    |    243,242 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 242,659 of 243,242    |
|    bart to All    |
|    Re: srand(0)    |
|    31 Dec 25 22:57:55    |
      From: bc@freeuk.com              On 31/12/2025 20:55, Lawrence D’Oliveiro wrote:       > On Wed, 31 Dec 2025 18:42:45 +0000, bart wrote:       >       >> In any case, it is easy enough to do a check on argc's value in your       >> applications. (And on Windows, if it is 0 and you really need the       >> path, you can get it with GetModuleFileNameA().)       >       > Remember that, on *nix systems, the contents of argv are arbitrary and       > caller-specified. And none of them need bear any relation to the       > actual filename of the invoked executable.       >       > In fact, it is quite common for utilities to behave differently based       > on the name, as passed in argv[0], by which they are invoked.              Yes, I do that all the time (especially from my other languages that       also make use of msvcrt.dll).              But, there is a difference between argv[0] and GetModuleFileName().              The latter returns the full path of the executable (which also then       allows you to pick up associated files in the same folder).              argv[0] merely returns what was typed on the command line to invoke the       application.              So if someone types:               C:\abc> prog              it may run a prog.exe found in, say, c:\programs\myapp, and return the       full path as "c:\programs\myapp\prog.exe".              args[0] will give you only "prog"; good luck with that!              I found out a few years ago that this useful funcion doesn't exist on       Unix-like systems. You have to do it a more complicated way that may or       may not work.              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca