标签:字符 写入 lin out 文件打开 stream class bsp main
#include <iostream> #include <fstream> using namespace std; int main() { char data[100]; ofstream outfile; // outfile.open("test.txt",ios::out|ios::in);文件打开模式可以省略,ofstream就是写对象 //test.txt如果不存在会自动创建 outfile.open("test.txt"); outfile << "hello c++"; cout << "writing something" << endl; cin.getline(data,100); outfile << data << endl; cin >> data; cin.ignore();//用来忽略指定字符 outfile << data << endl; outfile.close(); return 0; }
标签:字符 写入 lin out 文件打开 stream class bsp main
原文地址:http://www.cnblogs.com/zero2one/p/6973319.html