Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>1)</strong> It is supposed to be <code>char **argv</code> or <code>char *argv[]</code> which is <code>a pointer to an array of characters</code> more commonly known as <code>an array of strings</code> <br><br> <strong>2)</strong> <a href="http://www.cplusplus.com/reference/clibrary/cstring/" rel="nofollow">CString</a> is the std library to manipulate C strings (arrays of characters). You cannot resize an array without reallocating, but you can change the contents of elements by referencing it by index:</p> <pre><code>for(int i = 0; i &lt; argc; ++i) { //set all the strings to have a null character in the //first slot so all Cstring operations on this array, //will consider it a null (empty) string argv[i] = 0; } </code></pre> <p><br> <strong>3)</strong> Technically no, however they can be deleted then reallocated:</p> <pre><code>int *array = new int[15]; //array of size 15 delete[] array; array = new int[50]; //array of size 50 </code></pre> <p><strong>4)</strong> This is one way:</p> <pre><code>string *myString; if(argc &gt; 0) { myString = new string(argv[0]); for(int i = 1; i &lt; argc; ++i) myString-&gt;append(argv[i]); } </code></pre> <p><strong>5)</strong> Yes, according to Cubbi: </p> <blockquote> <p>POSIX specifies the final null pointer for argv, see for example "The application shall ensure that the last member of this array is a null pointer." at <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html" rel="nofollow">pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html</a></p> </blockquote> <p>Which means you can do:</p> <pre><code>char *val = NULL; int i = 0; do { val = argv[i++]; //access argv[i], store it in val, then increment i //do something with val } while(val != NULL); //loop until end of argv array </code></pre>
 

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