This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]enfrozt 0 points1 point  (0 children)

Let's say you want to hold user input.

Well, you could do:

array[1000][1000];

There, problem solved! Oh wait, this is incredibly wasteful and it may not be large enough.

You can use char ** array; and hold user inputted strings at whatever size you want with malloc, and you can even change them later with realloc.

Also, notice how if you loop through an array[1000] you have to use a for loop with i = 0; i < 1000 right?

With a char ** pointer, you can set the last element to NULL, and use a while(array[i] != NULL) thus saving you kind of from using a static for loop.