#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main()
{
ofstream wysla;
wysla.open("wysla.txt", ios::app);
int kaput;
string s1,s2;
cout<<"Please select from the List below"<<endl;
cout<<"1.New entry"<<endl;
cout<<"2.View Previous Entries"<<endl;
cout<<"3.Delete an entry"<<endl;
cin>>kaput;
switch (kaput)
{
case 1:
cout<<"Dear diary,"<<endl;
getline(cin,s1);
wysla<<s1;
wysla.close();
break;
}
return 0;
}
In this code I have tried to save a string of characters but it is not possible e.g,.. when I use getline nothing is saved on the text file when I use cin only the first word is saved. I would like to save the whole entry what do I do?