A filename as passed to fopen() (and other file creation operations) is a simple string, so you simply create the string you need, the process has nothing to do with filenames specifically, it is more generally applicable. For example:
char fname[32] ;
int seq ;
for( i = 0; i < 10000; i++ )
{
sprintf( fname, "rootname%4d.dat", i ) ;
Are you asking how to create filenames on the fly in a program, something like
wayne0001.txt
wayne0002.txt
etc.?
It seems you could do this (I do this all the time in Python) with string operations,
i.e. create your numbers, do an 'itoa' on them, can concatenate together into an
appropriate string representation of your filename.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is it possible to have dynamic file-names in C, I need to write data to 9000 + files
A filename as passed to fopen() (and other file creation operations) is a simple string, so you simply create the string you need, the process has nothing to do with filenames specifically, it is more generally applicable. For example:
char fname[32] ;
int seq ;
for( i = 0; i < 10000; i++ )
{
sprintf( fname, "rootname%4d.dat", i ) ;
}
The above creates the names:
rootname0000.dat
rootname0001.dat
rootname0003.dat
.
.
.
rootname9998.dat
rootname9999.dat
Clifford
Are you asking how to create filenames on the fly in a program, something like
wayne0001.txt
wayne0002.txt
etc.?
It seems you could do this (I do this all the time in Python) with string operations,
i.e. create your numbers, do an 'itoa' on them, can concatenate together into an
appropriate string representation of your filename.
Wayne