Program name: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: full -> full/name/base)
m (→‎{{header|C++}}: Reworded)
Line 469: Line 469:


=={{header|C++}}==
=={{header|C++}}==
C++ has difficulty accessing source code filenames, because C code must be compiled into an executable. However, C++ can access the executable's filename.
C++ can access the executable's filename through the arguments to main().


<lang cpp>#include <iostream>
<lang cpp>#include <iostream>
Line 478: Line 478:
char *program = argv[0];
char *program = argv[0];
cout << "Program: " << program << endl;
cout << "Program: " << program << endl;

return 0;
}</lang>
}</lang>