嗨,每一個我寫的代碼下面它是一個日記項目,它仍處於早期階段,所以當你運行它時,它假設告訴你輸入日記條目然後將其保存在文本中,但它不被保存在文件中,請幫助!我的程序輸入不會保存到一個文本文件
#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