Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have wrtiting a c++ program below: #include <fstream.h> #include <iostream.h>

ID: 3616006 • Letter: I

Question

I have wrtiting a c++ program below:

#include <fstream.h>
#include <iostream.h>
#include <stdio.h>
#include<conio.h>
//using namespace std;

int main()
{
   char FirstName[30], LastName[30];
   int Age;
   char FileName[255];
   char filename[30];
    cout << " Enter the name of the fileyou want to create: ";
   cin >> FileName;
   int a=10,b=12,c=13;
   
   
   sprintf(FileName, "%s,%i,%i,%i.txt", filename,a,b,c);

   cout << "Enter First Name: ";
   cin >> FirstName;
   cout << "Enter Last Name: ";
   cin >> LastName;
   cout << "Enter Age:       ";
   cin >> Age;

  
   ofstream Students(, ios::out);
   Students << FirstName << " "<< LastName << " " << Age;

   cout << " ";
  
   
   return 0;
}

This program creates an output file with the name specified by theuser form prompt e.g. test.txt. I am trying to print the values ofvariables a,b,c as part of the file name e.g. test12.13.14.txt.

Explanation / Answer

I recommend using the std::ostringstream class over sprintf as itis object oriented, and much safer. It works just like cout. Youneed to include the header sstream to use it. char filename[255]; int a = 10, b = 12, c = 13; cout