Using Malloc for i endless C -String
<p>I was wondering is it possible to create one endless array which can store endlessly long strings?</p>

<p>So what I exactly mean is, I want to create a function which gets i Strings with n length.I want to input infinite strings in the program which can be infinite characters long! </p>

<pre><code>void endless(int i){
     //store user input on char array i times 
}
</code></pre>

<p>To achieve that I need malloc, which I would normally use like this:</p>

<pre><code>string = malloc(sizeof(char));
</code></pre>

<p>But how would that work for lets say 5 or 10 arrays or even a endless stream of arrays? Or is this not possible?</p>

<p>Edit:
I do know memory is not endless, what I mean is if it where infinite how would you try to achieve it? Or maybe just allocate memory until all memory is used?</p>

<p>Edit 2:
So I played around a little and this came out:</p>

<pre><code>void endless (char* array[], int numbersOfArrays){
int j;

//allocate memory
for (j = 0; j &lt; numbersOfArrays; j++){
    array[j] = (char *) malloc(1024*1024*1024);
}

//scan strings
for (j = 0; j &lt; numbersOfArrays; j++){
    scanf("%s",array[j]);
    array[j] = realloc(array[j],strlen(array[j]+1));
}

//print stringd
for (j = 0; j &lt; numbersOfArrays; j++){
    printf("%s\n",array[j]);
}
}
</code></pre>

<p>However this isn't working maybe I got the realloc part terrible wrong? </p>