Path: utzoo!attcan!uunet!mcvax!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.sys.atari.st Subject: Re: Megamax v1.1 Bug? Message-ID: <505@philmds.UUCP> Date: 13 Jun 88 11:04:58 GMT References: <544@wsccs.UUCP> <46700006@hcx1> Reply-To: leo@philmds.UUCP (L.J.M. de Wit) Organization: Philips I&E DTS Eindhoven Lines: 30 In article <46700006@hcx1> devon@hcx1.SSD.HARRIS.COM writes: argc will always be at least 1. This is because the first parameter passed (*argv[0]) will always be the name of the program. If an actual parameter is passed from the shell argc will be 2 and the parameter will be found in *argv[1]. A call with no parameters generates: % ls argc=1 *argv[0]="ls" whereas a call with multiple parameters generates: % ls file1 file2 argc=3 *argv[0]="ls" *argv[1]="file1" *argv[2]="file2" It should be noted that this is not a bug in the libraries but conforms exactly to the UNIX/C standards and is well documented in the K&R bible. Everywhere you write '*argv' this should be: 'argv'. Note that argv is declared char *argv[]; this means argv points to an array of pointers to char. E.g. argv[1] is such a pointer, *argv[1] is the first character of the string argv[1] points to. Note also that for the ST the name of the program is NOT passed; this is because what the program really gets is an arguments line, that it has to scan itself. The startup code that is linked with your modules should take care of that; there is generally no way for it to determine the name it was called with (some startup code make it a null pointer but I don't think this is correct: in Un*x the first null pointer determines the end of the list) . In Un*x the arguments and environment string arrays are already there when the program starts. Leo.