✔ 最佳答案
As long as I understand, C does not support manipulating a list of files, but you can use a structure to help, e.g.:
typedef struct {
FILE* pt;
char* name;
char status;
} File_desciptor;
File_desciptor file[100];
void open_all () {
int i;
for (i=0;i<100;i++) {
file[i].pt = fopen(file[i].name, "rw+"); file[].status = OPEN;
//assume you have define a value of OPEN
}
}
void write_to(char* name, int k) {
int i;
for (i=0;i<100;i++) if (strcmp(name, file[i].name) == 0) break;
if (i >= 100) printf("file does not exist");
fprintf(file[i], "%D", k);
}
...