Adding on a suffix to a file

So I need to add the suffix .radar onto a filename taken in by a user. I am at a loss on how to even start to do that, this is my code so far.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main ()
{
	cout << "Hey guys! Butterfly girl here, I created the program" << endl;
	cout << "Super Hero Object Location Generator" << endl;

	ofstream myfile;
	string file_name;
	cout << "What should I name the file?" << endl;
	cin >> file_name;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main ()
{
	cout << "Less words, more work" << endl;

	ofstream myfile;
	string file_name;
	cout << "What should I name the file?" << endl;
	cin >> file_name;
        file_name += ".radar";
        cout << "Here's an early Christmas present." << endl;
        cout << file_name;
}
Last edited on
Thank you for the early christmas present
Topic archived. No new replies allowed.