+ 4
Write a program to print the name of .exe file.
5 ответов
0
In sololearn compiler, you have to explicitly put, for example, main (const int argc, const char**) in order to use the arguments.
+ 3
The name of the file is inside variable arg[0]. It is a char*, or C string.
+ 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];
}
+ 1
Thought so, thanks for checking
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.