append a file

Hey,

I've made a function which print out a container to a text-file.

Now I would like to rebuild this function. It has to append the container to a text-file(1) and make a copy of that text-file(1) to another text-file(2).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
void print_F(std::map <std::string, Person>& p)
{
	std::ofstream printfile;
	printfile.open ("adressbook.txt");

	std::map<std::string, Person>::iterator print;
	print=p.begin();

	if (print == p.end())
	{
		printfile << "Adressbook is empty." << std::endl;
		std::cout << "There are no information in the adressbook." << std::endl;
	}
	else
	{
	while(print != p.end())
		{
			printfile << print-> second.name << std::endl;
			printfile << print-> second.adr << std::endl;
			printfile << "Phone. " << print-> second.phone << std::endl << std::endl;     
			print++;
		}

	printfile.close();
	}
	std::cout << "All contacts are now printet to the file: adressbook.txt";
};
Topic archived. No new replies allowed.