Are both of them really a void? Plus if you are using int or char in your program
wouldn't be better to have int main(int, char)
Thanks
Edited by ShaunM, 02 January 2012 - 05:37 PM.
Edited by ShaunM, 02 January 2012 - 05:37 PM.
|
|
|
int main(int argc, char **argv)
{
\\Some code...
}
the argc and argv are used for getting arguments from the command line: argc has the count of arguments and **argv is an array of strings, each string an argument. If you don't plan to use command line arguments you can leave out the argc and argv and get int main().
#include <stdio.h>
int main(int argc, char **argv)
{
printf("%s", argv[0]);
return 0;
}
This would simply print out the name of your program.
#include <stdio.h>
int main(int argc, char **argv)
{
int i;
for(i = 0; i < argc; i++)
{
printf("%s", argv[i]);
}
return 0;
}
I hope this helps you understand
0 members, 1 guests, 0 anonymous users