Dynamic array of pointers
Hi. I'm learning about pointers and as an exercise I'm trying to create a program that will store an unknown number of pointers to strings that will be input by the user in an array of pointers.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char input[100];
char **strings;
do {
printf("Type something: ");
fgets(input, sizeof(input), stdin);
/* I don't know what to do now */
} while (strcmp(input, "exit") != 0);
/* free the memory that was allocated */
return 0;
}
If I was using something like
Code:
char *strings[5000];
then I'd know what to do but using **strings is confusing me. Anyone can give me a hint? Thanks.