Time card program

Hey guys im making a timeclock program i wanted to get some ideas


if (choice == 1) { outputfile.open("C:\\Users\\Lucas\\Documents\\LUCAS\\source\\lucdes-IN.txt");
outputfile << asctime(localtm);
outputfile.close();
cout << "punch complete! \a";

this is the line to create and output file with the employee's punch times but i wanted to know how i could make it to were we can make the file name different each time by letting the user write the name.. any help would be great . and i know in a begginner so please so bash me either
1
2
3
4
5
6
string filename;

cout << "Enter the filename: ";
cin  >> filename;

outputfile.open(filename.c_str());
But in that case how would i control the path? unless i made another one
string path;
Last edited on
Yes you could do this:

1
2
3
4
5
6
7
8
9
string filename;
string path = "C:/Users/Lucas/Documents/LUCAS/source/";
string location;

cout << "Enter the filename: ";
cin  >> filename;
location = path + filename;

outputfile.open(location.c_str());
Topic archived. No new replies allowed.