create files with specified name

I want to create 100 files with the increment of file names included..

for example the file name are :

file #1
file #2
file #3 etc

I tried but fail, I stuck at how to convert the int increment variable into string.. help..
The simplest way (although not the best) is to use a stringstream:

1
2
3
4
5
6
template <class T> std::string to_string(const T& v)
{
    std::stringstream ss;
    ss << v;
    return ss.str();
}
i like to do this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
savefile.exceptions(std::ofstream::failbit | std::ofstream::badbit);
        std::cout << "Enter a title for your webpage: ";
        getline(std::cin, filename); 
        hold = filename;
        filename = "/Users/home/Desktop/project/seven/"; 
        filename += hold; 
        filename += ".html"; 
        try{
            savefile.open(filename.c_str());
        }
        catch (std::ofstream::failure &e){
            std::cout << "An error has occured";
            return false; 
        }

this is some code from an old project i did.
can u guys give me full code? my college even din't teach class (shit)..
C#

for (int i = 0; i < 100; i++) File.Create(i.ToString() + ".txt");

C++

HELP :(
that code i gave you. that takes file name from user, sets its location, and says type of file. then opens the save file. what else could you want?
Topic archived. No new replies allowed.