假设文件能够正常打开,下面程序会把 Welcome 写入 log.txt。 int main() { ofstream fout("log.txt"); fout << "Welcome"; fout.close(); return 0; }