C++ 当I';我正在使用流对象和管道输出写入同一个文件?
这是代码:C++ 当I';我正在使用流对象和管道输出写入同一个文件?,c++,file,file-io,pipe,fstream,C++,File,File Io,Pipe,Fstream,这是代码: #include<iostream> #include<fstream> using namespace std; int main(){ ofstream out("file.txt"); //cout<<"I'm being written on console and piped to file."<<endl; out<<"I'm directly being written on file us
#include<iostream>
#include<fstream>
using namespace std;
int main(){
ofstream out("file.txt");
//cout<<"I'm being written on console and piped to file."<<endl;
out<<"I'm directly being written on file using ofstream object"<<endl;
cout<<"I'm being written on console and piped to file."<<endl;
}
在档案里,猜猜我发现了什么
I'm being written on console and piped to file.
m object
请有人解释一下。。。
提前谢谢 如果您成功地打开了同一个文件两次,那么两个流都从文件的开头开始写入,我并不感到惊讶。C++规范中没有任何东西可以说它应该与shell同步输出。你期待什么?
I'm being written on console and piped to file.
m object