Topic : C-Language Documentation Author : John Kormylo Version : C.HYP 1.0 Subject : Documentation/C-Language Nodes : 233 Index Size : 6362 HCP-Version : 3 Compiled on : Atari @charset : atarist @lang : en @default : @help : Help @options : +g -i -s +x +z -t4 @width : 75 View Ref-File[ main ] Function main() is called by PCSTART, PCXSTART or PCVSTART. Syntax: int main(void) { <code> } int main(int argc, char* argv[], char** envp ) { <code> } argc - number of elements in argv[]. argv[0] - NULL string under TOS (program name under UNIX). argv[1] - first parameter in command line (usually a filename). ... argv[argc] - NULL string. envp - Pointer to environment parameter list, which is a series of consecutive NULL terminated strings of the form "name=descripton", ending with a NULL string. The return value is used as a program completion code, where 0 means no errors, <0 for system errors, and >0 for user errors. The second form of main() is used primarily for *.TTP programs, where a command line can be entered at run time, or for subprograms of a shell program. It can also be used by *.PRG programs using the 'Install Application' feature of GEMDOS, where opening a file with a special extension will start up the selected application, or by dragging a file onto an application icon. The name of the file is passed to the application as the only command line parameter. Environment parameters are another way for programs to communicate with one another. Since command lines are limitted to 127 characters, one can use environment parameter "ARGV=..." to pass longer command lines (see PCVSTART). However, TOS doesn't really support environment parameters (without a TOS shell). Note: Calling Fsfirst() will overwrite the command line!