svaing my information to .dat file

i have wrote my code which ask for weight and height but every time i enter my information which will replace the previous information from my .dat file I want know how to keep the information that I enter every time instead of replace the previous. For example I enter my weight twice like 150 and 160 and they all show up in my file. Here is my code

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 int Addbiometric()
{  char x;

   std::cout<<"To Add Weight: Type W\n";
   std::cout<<"To Add Height: Type H\n";
   std::cout<<"Selection>";
   std::cin>>x;

if ( x = 'W||w')
{


    std::cout<<"Enter the Weight in pounds:\n";
    std::cin>>a;
    output.open("heath_record.dat");

		if (output.fail()){
			std::cerr << "File creation failed.\n";
			return 1;
		}
		output << "W" << ' ' << a <<std::endl;
        std::cout<< "Health Records are printed to file: health_record.dat";

		output.close();
    std::cout<<"Biometric Added\n";
    return 0;
}
else if (x = 'H||h')
{


    std::cout<<"Enter the Hight in feet:\n";
    std::cin>>b;
    std::cout<<"Biometric Added\n";
    return 0;
}




}
Topic archived. No new replies allowed.