taking length of predefined string vs getting one from input : <p>I seem to be unable to understand why do these two cases behave differently:</p>

<pre><code>const char* TEXT = "hello world!";
int length = (int) strlen(TEXT);
char* array[length];
</code></pre>

<p>this is ok, however this one:</p>

<pre><code>char* text;
scanf("%[^\n]s", text);
// input "hello world!" and press enter
int length = (int) strlen(text);
char* array[length];
</code></pre>

<p>ends with a segmentation fault</p>

<p>what am I missing?</p>
