How to create simple database?

Hey, I'm new to C++ programming and trying to create a program that stores 3 string inputs (s1,s2,s3), entered in keyboard. I made an excel csv file. The input data then outputs to the csv file, which works ok. But every time i run the program, it overwrites the previously entered data. Can anyone suggest a simple database those collects and saves the input data every time. Thanks

This is my main program:

#include <iostream>
#include <fstream>
#include <vector>
#include <string>

using namespace std;

int main()
{
string s1,s2,s3;
ofstream MyExcelFile;
MyExcelFile.open ("Numbers.csv");
cout << "Welcome To C++ Account Manager";
cout << "" << endl << "";
cout << "" << endl << "";
cout << "Please Enter Your Name: ";
cin >> s1;
MyExcelFile << s1 << endl;
cout << "Name Is: " << s1;
cout << "" << endl << "";
cout << "" << endl << "";
cout << "Please Enter Account Number: ";
cin >> s2;
MyExcelFile << s2 << endl;
cout << "Account Number Is: " << s2;
cout << "" << endl << "";
cout << "" << endl << "";
cout << "Please Enter Account Password: ";
cin >> s3;
MyExcelFile << s3 << endl;
MyExcelFile.close();
cout << "" << endl << "";
cout << "" << endl << "";
cout << "Account Details Saved";
cout << "" << endl << "";
cout << "" << endl << "";
return 0;
}
Last edited on
MyExcelFile.open("Numbers.csv", ios::out | ios::ate | ios::app) ;
opens MyExcelFile for output, seeks to the end of the file on open and all output is appended to the file.

You aren't outputting any commas, which seems a little unusual for a csv file.
Thanks so much, it now works exactly how I want. Thanks!
Topic archived. No new replies allowed.