hi all
i want to create an array of files. but the size of the array is not given initially, but will be read from user input. i tried this but it didn't work.
Code:#include <stdlib.h> #include <stdio.h> int main(){ FILE *fp; int t; int i; char filename[50]; t = 8; //will be read from user input actually fp = malloc (t * sizeof(FILE*) ); for ( i=0; i<t; ++i){ sprintf (filename, "%d.txt", i); fp[i] = fopen("filename", "w"); } return 0; }