> int main(void) { }
Code:
#include <stdio.h>
#include <windows.h>
int main ( void )
{
char * autotext = "This is an example of automatic text.";
char * ptrtext;
for ( ptrtext = autotext; * ptrtext != '\0'; ptrtext++ )
{
Sleep(100);
printf("%c", * ptrtext);
}
return 0;
}
> int main ( int argc, char * argv[] )
Code:
#include <stdio.h>
void DefaultMessage ( void );
int main ( int argc, char * argv[] )
{
if (argc == 2)
/* if there was a parameter besides the path to this program */
{
if(argv[1][0] == '?')
/* if the parameter was a question mark */
{
printf("Help stuff would go here.\n");
}
else
/* if the parameter was not a question mark, print whatever it was */
{
printf("%s \n", argv[1]);
}
}
else if ( argc >= 3 )
/* if there were 2 or more parameters besides the path to the program */
{
printf("Invalid input:\n");
printf("Only one command-line parameter allowed.\n");
}
else
/* if there were no paramters at all */
{
DefaultMessage();
}
return 0;
}
void DefaultMessage ( void )
{
printf("CmdLine.exe:\n");
printf("The purpose of this program is to demonstrate command line arguments.\n");
printf("This program will print whatever you type on the screen.\n\n");
printf("Example:\n");
printf("C:\\>CmdLine.exe Hmmm\n");
printf("Hmmm\n");
}
(To put each implimentation of main, into code perspective)
> I teach int main().
It's a good thing(TM).
> momo20016
Just use int main.