嗨,每一个我写的代码下面它是一个日记项目,它仍处于早期阶段,所以当你运行它时,它假设告诉你输入日记条目然后将其保存在文本中,但它不被保存在文件中,请帮助!我的程序输入不会保存到一个文本文件
#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;
cin>>s1;
wysla<<s1;
wysla.close();
break;
}
return 0;
}
是啊有一个想通了,以后,谢谢enewei .. – Wysla 2013-04-26 07:21:52
在同一个程序中,当我输入一个长字符串时,它只能选择第一个字..当我尝试使用getline字符串isn,t保存在文本文件中应该什么我做? – Wysla 2013-04-26 07:24:15