I have seen arguments in the main function. But I couldn't find reference about them .
Could anyone explain me why there are arguments, and what do they do?
However i think that (as a noob my self who has done a few months of programming) I could not understand the explanations given to me so it seems like one of those things you just got to wait untill you know about programming. :(
Command-line arguments. start->run, type 'notepad test', this will run notepad and pass "test" as an argument to notepads main function. Notepad attempts to open a file named test.txt.
int main(int argc, char *argv[])
argc is the number of arguments received. If I remember correctly the first argument is always the name of whatever executable you are launching, so argc should always be atleast 1. argv is an array of pointers to strings.
Assuming I created an app and launched it like so.. "someapplication.exe whats up doc!",
1 2 3 4 5 6 7 8
int main(int argc, char *argv[])
{
for(int i = 0, i < argc; i++)
{
cout << argv[i] << endl
}
return 0;
}