I'm trying to write a program that will save "X" number of simple textfiles- however, X is determined by the user once the program has run. I can't seem to find any help on the net as to how to solve the following two things, so any tips will be massively appreciated!

1) How do I declare these textfiles at the start of the program if I don't know how many there will be?

* So far, I'm used to using:

```
FILE* outfile;

```
* But what I really need is:

```
FILE* outfile_0, outfile_1, outfile_2... outfile_X;

```
* The solution that comes to mind looks like a loop, but I know that this won't work!

```
for (i=0;I<X;i++){
    FILE* outfile_i     // obviously, this just literally calls it "outfile_i" 
}

```

2) How do I name them?

* I want to call them simple names, such as "textfile\_1, textfile\_2" etc, but I don't see how that would be possible using:

```
outfile=fopen("C:\\textfile.txt","w");

```
* Again, I thought perhaps making a loop (?!) but I know that this won't work:

```
for(i=0;i<X;i++){
    outfile_i=fopen("C:\\textfile_i.txt","w");
}

```

There's absolutely no way of knowing what variable "X" is before running the program.

EDIT: Problem solved- I wasn't aware you could create arrays of "FILE\*", thanks for all the help!