Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is not always. It's the value that you gave the program by the Operation System. For example when starting a program using <code>exec</code> you can set that to an arbitrary value:</p> <pre><code>int execve(const char *filename, char *const argv[], char *const envp[]); </code></pre> <p>The first parameter is the file to start, and argv will contains argv[0] and all other parameters for main. envp contains the environment variables (not defined by Standard C or C++. This is a posix thing). </p> <p>More precisely, this is the definition of argv in C++:</p> <blockquote> <p>An implementation shall not predefine the main function. This function shall not be overloaded. It shall have a return type of type int, but otherwise its type is implementation-defined. All implementations shall allow both of the following definitions of main:</p> </blockquote> <pre><code>int main() { /* ... */ } </code></pre> <blockquote> <p>and</p> </blockquote> <pre><code>int main(int argc, char* argv[]) { /* ... */ } </code></pre> <blockquote> <p>In the latter form argc shall be the number of arguments passed to the program from the environment in which the program is run. If argc is nonzero these arguments shall be supplied in <code>argv[0]</code> through <code>argv[argc-1]</code> as pointers to the initial characters of null-terminated multibyte strings (NTMBSs) (17.3.2.1.3.2) and <code>argv[0]</code> shall be the pointer to the initial character of a NTMBS that represents the name used to invoke the program or "". The value of argc shall be nonnegative. The value of <code>argv[argc]</code> shall be 0. [Note: it is recommended that any further (optional) parameters be added after argv. ]</p> </blockquote> <p>It's pretty much up to the implementation what defines a "name used to invoke the program". If you want to get the full path of your executable, you can use <a href="http://msdn.microsoft.com/en-us/library/ms683197%28VS.85%29.aspx" rel="noreferrer">GetModuleFileName</a> on Windows, and <code>argv[0]</code> (for getting the name used to execute, may be relative) together with <code>getcwd</code> (for getting the current working directory, trying to make the name absolute).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload