I am trying to define a dynamic array containing char pointers that point to strings. The string can be of any length, so i used char pointers. I want to dynamically resize the array each time I need to store more values. The following code gives me segmentation fault. Am I doing it well?
int main() {
char **input=NULL;
char *buffer;
int i=0;
do {
input = (char **)realloc(input, (i+1) * sizeof(char *));
scanf("%s", &buffer);
strcpy(input[i++],buffer);
} while(strlen(buffer)!=0);
}