+ 2
Can you pass an argument to the main function??
main function in c++ is the starting point of program exectution
7 Respostas
+ 3
In the playground you cannot. If you start you program via a command prompt you would do something like this
MyProgram.exe first
With "first" being the first argument.
In visual studio there is setting to add arguments
+ 3
Yes this is possible if you use main(int argc, char* argv[]) in your code.
Say your file is named "foo.cpp"
Then, after compiling, you can call it in your console with additional parameters like
./foo test1 test2
Then argc is 3 and
argv[0] : ./foo
argv[1]: test1
argv[2]: test2
But I'm afraid you can't do this in Sololearn
+ 2
Tap the { } on the menu bar. It is a place to code online in the Sololearn app or website.
How do you use Sololearn ? Phone or web ?
What ide do you use ?
+ 2
Muhammad Kaleem Ullah Cool. Looks good IDE. You definitly can add command line arguments in there using the method of swim
+ 1
sneeze i used turbo c++ and dev and
heard turbo is more reliable
0
Muhammad Kaleem Ullah Do you mean Sololearn playground or visual studio ?
0
What's sololearn Playground