You have the worst luck . . . post it in the C forum and get "don't use new", post it here and get "don't use C file functions".
What you want is realloc(). Look it up and/or examine this C program (I wrote it in one sitting, it probably isn't perfect):
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char **s = 0, **p;
char line[BUFSIZ];
int x, lines = 0;
while(fgets(line, sizeof(line), stdin)) {
p = realloc(s, sizeof(char *) * (lines+1));
if(!p) {
perror("Out of memory");
exit(1);
}
s = p;
s[lines] = malloc(strlen(line)+1);
strcpy(s[lines++], line);
}
for(x = 0; x < lines; x ++) {
printf("%i: %s", x, s[x]);
free(s[x]);
}
free(s);
return 0;
}