+ 4

Write a program to print the name of .exe file.

26th Jul 2017, 6:58 AM
Shwati Kumari
Shwati Kumari - avatar
5 Answers
0
In sololearn compiler, you have to explicitly put, for example, main (const int argc, const char**) in order to use the arguments.
26th Jul 2017, 3:20 PM
Denis Felipe
Denis Felipe - avatar
+ 3
The name of the file is inside variable arg[0]. It is a char*, or C string.
26th Jul 2017, 7:48 AM
Denis Felipe
Denis Felipe - avatar
+ 1
Like @Denis Felipe said, but you have to to pass (int argc,char* argv[]) arguments to main, at least you had to in C. it'd be something like this: int main(int argc,char* argv[]){ cout<<argv[0]; }
26th Jul 2017, 1:03 PM
Nikola Kesic
Nikola Kesic - avatar
+ 1
Thought so, thanks for checking
26th Jul 2017, 3:21 PM
Nikola Kesic
Nikola Kesic - avatar
0
I am quite sure you can use argc and argv even when you don't explicitly put it in the main parameters. Will test here fast.
26th Jul 2017, 3:14 PM
Denis Felipe
Denis Felipe - avatar