Generating files with different names at runtime

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,c2,c3 etc.. Is there any way to do it??
Thanks!

Replies

  • Anoop Kumar
    Anoop Kumar
    What language you are using?
    Generate file using _.
  • Vishal Sharma
    Vishal Sharma
    ianoop
    What language you are using?
    Generate file using _.
    oh... forgot to mention that!! i'm programming it in C++
  • rahul69
    rahul69
    Vishal0203
    oh... forgot to mention that!! i'm programming it in C++
    Then it is quite simple😉
    • Take a file name e.g. Student, so ur files will be named like student1,student2 etc.
    • Run a loop for the no. of students.
    • Append the index name with the file name to create final file name.
    • Append this final file name with ".txt" or whatever format u want.
    • Using this final file name create the new file.
    • Write to that file and close that file
    In this process take care that u first convert index to string before appending/concatinating with the file name to get the final file name.😁
  • Vishal Sharma
    Vishal Sharma
    what if i want to rename the file during runtime??? I mean, after manipulating the things in file (which is already existing), i want to rename it and save it as different file so that the overlapping of main file doesn't occur!!
  • grsalvi
    grsalvi
    Vishal0203
    what if i want to rename the file during runtime??? I mean, after manipulating the things in file (which is already existing), i want to rename it and save it as different file so that the overlapping of main file doesn't occur!!
    After editing a existing file if you want to save to new file with new name :

    create a function which creates two fstreams , one for input and another for output.

    create appropriate name for destination file (you may append source file name with temp.txt).
    use input file stream to read the source file ,and out put the content as it is to destination file as it is.

    After successful copying if you want to delete source file,use system command :
    delete with the file name.
  • Vishal Sharma
    Vishal Sharma
    grsalvi
    After editing a existing file if you want to save to new file with new name :

    create a function which creates two fstreams , one for input and another for output.

    create appropriate name for destination file (you may append source file name with temp.txt).
    use input file stream to read the source file ,and out put the content as it is to destination file as it is.

    After successful copying if you want to delete source file,use system command :
    delete with the file name.
    That's a very big procedure.. I got it in an easier way! 😀 I used c_str() and got it!
    Thanks everyone!!
  • rahul69
    rahul69
    Vishal0203
    That's a very big procedure.. I got it in an easier way! 😀 I used c_str() and got it!
    Thanks everyone!!
    Could u please explain a little more as how did u renamed the file using c_str()?? As far as I know c_str is used for conversion of string object into character array,so how did u used it for renaming?
  • Vishal Sharma
    Vishal Sharma
    rahul69
    Could u please explain a little more as how did u renamed the file using c_str()?? As far as I know c_str is used for conversion of string object into character array,so how did u used it for renaming?
    Actually, i didn't rename it.. I allowed the user to enter the file name the file is generated as
    name += ".doc";
    fstream file (name.c_str());
    
    and instead of renaming the main file, I copied the contents of main file in to the generated file.. This seems much better than renaming it..

You are reading an archived discussion.

Related Posts

A Slower Speed of Light is a first-person game in which players navigate a 3D space while picking up orbs that reduce the speed of light in increments. A custom-built,...
I have created a frame..see uploaded file...if we resize it ..I want controls (labels,textboxes,button) arranged properly and size according to frame size... Control's size should be arranged as per frame's...
I've been flipping the pages on the Internet to find out whether the recently launched MacBook Pro 13" has been launched in India. I just got an email from Apple...
It seems that the Android 4.1 Jelly Bean is rolling out for the Galaxy S3 phones in India. The firmware is being made available through Kies software and also over...
Study conducted by Ericsson ConsumerLab shows that an average of 1 hour and 7 minutes are spent by the Generation z [youngsters between 9 - 18 ] on Facebook. Approximately...