A
Aris
Hi all!
I want to make a function which will create file names as :
I will load with an integer
from 1 till 5 and receive a responce like this
"file1.txt","file2.txt"....."file5.txt"
But instead I get crazy things like theese:
file1.txt
file1.txt2
file1.txt23
file1.txt233@
can you help me?
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char * Create_File_Name(int counter_files)
{
char *ch1="file";
char *ch2=".txt";
char string[2];
itoa(counter_files,string,10);
char *ch3=strcat(ch1,string);
char *fname=strcat(ch3,".txt");
return fname;
}
int main()
{
char* fname;
for(int i=1; i<5; i++)
{
fname=Create_File_Name(i);
cout<<fname<<endl;
}
int p;
cin>>p;
return 0;
}
I want to make a function which will create file names as :
I will load with an integer
from 1 till 5 and receive a responce like this
"file1.txt","file2.txt"....."file5.txt"
But instead I get crazy things like theese:
file1.txt
file1.txt2
file1.txt23
file1.txt233@
can you help me?
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char * Create_File_Name(int counter_files)
{
char *ch1="file";
char *ch2=".txt";
char string[2];
itoa(counter_files,string,10);
char *ch3=strcat(ch1,string);
char *fname=strcat(ch3,".txt");
return fname;
}
int main()
{
char* fname;
for(int i=1; i<5; i++)
{
fname=Create_File_Name(i);
cout<<fname<<endl;
}
int p;
cin>>p;
return 0;
}