#include <iostream> #include <fstream> #include <string> using namespace std; int main() { string content; cout << "input your content:" << endl; cin >> name; ofstream outfile("notebook.txt"); if (!outfile) { cout << "File cannot be opened." << endl; return 0; } cout << "what you input is:" << content << endl; outfile << content; outfile.close(); string show; cout << "do you want to show the file?0/1" << endl; int i; cin >> i; if (i = 0) return 0; ifstream infile("name.txt"); infile >> show; cout << "the file is:" << endl; cout << show; infile.close(); }
本人在学习输入输出流时,想做一个记事本,但是发现如果输入内容中有空格号就会丢失后面的内容,请问大虾如何能把我要记录的内容原原本本地保留下来?是基于输入输出流的知识的哦,感谢