Re: help9 c++
You can't opene more than N files, where N is OS dependent value. Other than that, just generate file name when trying to open the file like this:
char name[128];
FILE *fp;
int i = 0;
sprintf(name."%s%02d.bin". "name", i); /* now the name is name01.bin and we can open 100 files with name00 to name99 */
fp = fopen(name, "wb"); /* write over old file */
.....
Is this what you were looking for?
Added after 5 minutes:
Here is the small test program which will create 100 files:
#include <stdio.h>
#include <errno.h>
int main(void)
{
char name[128];
FILE *fp;
int i = 0, j;
for (i=0; i<100; i++)
{
sprintf(name,"%s%02d.bin", "name", i); /* now the name is name01.bin and we can open 100 files with name00 to name99 */
fp = fopen(name, "wb"); /* write over old file */
if (fp == NULL)
{
printf("Create file %s failed. Errno = %d\n", name, errno);
return errno;
}
fclose(fp);
}
return 0;
}