From: Keith M. <kei...@us...> - 2012-04-20 19:53:33
|
Please DO NOT top post. On 20/04/12 13:28, Ji...@t-... wrote: > I just tried Pierre's suggestion and it work now perfectly. It will do; yet, you would be well advised to pay no heed to the misconception it promotes. It is NOT necessary to write your main function thus: int main (int argc, char **argv) { ... The point Roger was making, is that it is necessary to actually write it to clearly identify it as a function, but: int main () { ... is sufficient for that; it was the absence of any parentheses, indicating the presence of an (even empty) argument list, (which is required when defining, or invoking any function), which caused your original example to fail. Eli has already offered the most complete, and accurate advice, and I will not repeat it; yet even he neglected to mention the full prototype for the main function: int main (int argc, char *argv[], char *envp[]); Perhaps he was just attempting to avoid potential confusion; the most frequently used forms are: int main (int argc, char *argv[]); when you want to use the command line arguments, or simply: int main (); when you don't, (as is the case in your example, so this latter form is most appropriate in this particular case). I'll definitely second Eli's final words of advice -- get yourself a good book on C programming, and follow the examples therein. -- Regards, Keith. |