hi everyone!
I'm working on project which Generates certificates for different students.
The interface takes the input of Name, College, Secured position and generates the certificate...
but I want to generate all the certificates at once. So, to avoid overlapping of the file names, i want to generate different file names during runtime like c1,c3,c3 etc.. Is there any way to do it??

Thanks!

Something like this:

// C++11
std::string generate_file_name( const std::string& name, const std::string& college )
{
    static int slno = 0 ;
    return name + '_' + college + '_' + std::to_string( ++slno ) ;
}


// or C++98
std::string generate_file_name( const std::string& name, const std::string& college )
{
    static int slno = 0 ;
    std::ostringstream stm ;
    stm << name << '_' << college << '_' << ++slno ;
    return stm.str() ;
}

I already have a certificate file made with the necessary spaces at necessary locations..
after manipulating that file, can we save it with a different name?? So that it doesn't change anything in the main certificate file (wich has blanks left) ??

Just take the original file name and append something to it

std::string name = "Hello";
std::string newname = name + "There";

ofstream out(newname.c_str());

Or, if you want to keep the same name just put the new file(s) in a different folder by appending the new path to the folder to the beginning of the file name.

Edited 4 Years Ago by Ancient Dragon

This question has already been answered. Start a new discussion instead.