Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>char *arr2[1];</code> is an array with one element (allocated on the stack) of type "pointer to char". <code>arr2[0]</code> is the first element in that array. <code>arr2[1]</code> is undefined.</p> <p><code>char **arr2=NULL;</code> is a pointer to "pointer to char". Note that <em>no</em> memory is allocated on the stack. <code>arr2[0]</code> is undefined.</p> <p>Bottom line, <strong>neither of your versions is correct.</strong> That the second variant is "running perfectly fine" is just a reminder that buggy code can <em>appear</em> to run correctly, until negligent programming really <em>bites</em> you later on and makes you waste hours and days in debugging because you trashed the stack.</p> <p><strong>Edit:</strong> Further "offenses" in the code:</p> <ol> <li>String literals are of type <code>char const *</code>, and don't you forget the <code>const</code>.</li> <li>It is common (and recommended) practice to indent the code of a function.</li> <li>It is (IMHO) good practice to add spaces in various places to increase readability (e.g. post <code>(</code>, pre <code>)</code>, pre and post binary operators, post <code>;</code> in the <code>for</code> statement etc.). Tastes differ, and there is a vocal faction that actually <em>encourages</em> leaving out spaces wherever possible, but you didn't even do <em>that</em> consistently - and <em>consistency</em> <strong>is</strong> universially recommended. Try code reformatters like <a href="http://astyle.sourceforge.net/" rel="nofollow">astyle</a> and see what they can do for readability.</li> </ol>
    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