I'm developing a C ++ program that should read the keyboard data by storing them with hash , after reading it it should have the save option in its main menu.
I can read the save files using hash and everything.
The problem is when creating the file, I would like to make a for you to create the files with the default name, example
data_1
data_2
data_3
assim por diante
I made this code, but for some reason it creates only the zero index file and as if repeating the name and replacing the file 4 times that is the size of the defines TAM
;
void func_arquivo::cria_arquivo(){
ofstream arquivo;
for(int i=0;i<TAM;i++){
char nome[TAM];
sprintf(nome, "Data-%d.txt",i);
arquivo.open(nome, ios::app);
arquivo.close();
}
}