I had my fingers crossed that "dynamic" meant something more "automatic", but anyway, for posterity's sake, here's what I worked out re: reading a file into one character array:
Code:
char *func (char *filename) {
size_t len, tmem = 0;
char *cumul, *line;
FILE *fst = fopen(filename, "r");
if (fst == NULL) puts("!!fopen failed!");
while ((line = linein(fst)) != NULL) {
len = strlen(line);
if (mem = 0) {
mem = len+1;
cumul = (char *)malloc(mem);
strcpy(cumul,line);
}
else {
mem += len;
cumul = (char *)realloc(mem);
strcat(cumul,line);
}
}
return cumul;
}
"linein" is another function but I think the point is clear...thanx all (ps. is there a simpler way at all??)