入门计划->使用(C++库)ofstream写文件数据
2003-07-30 16:52
495 查看
原创+收藏
//awzzz@2002 //入门计划->使用(C++库)ofstream写文件数据 //APO->using ofstream. //accidence project of using ofstream.(c++ iostream library) /* Reference: http://www.cplusplus.com/ref/iostream/ofstream/ Description ofstream class provides a stream interface to write data to files. The class mantains internally (privately) a pointer to a filebuf object in charge of the interaction with the file. This pointer can be obtained/modified by calling member rdbuf. The file to be processed can be specified as a parameter for the constructor or by calling member open. After a file is processed it can be closed by calling member close. In this case the file stream may be used to open another file. Member is_open can be used to determine wether the stream is currently operating on a file or not. Please refer to parent classes for more details on information mantained by an ofstream object. */ //使用(C++库)ofstream写文件数据 //simple example #include <iostream> #include <fstream> using namespace std; #ifdef WIN32 #define TEST_FILE "c://tmp//test.txt" #else #define TEST_FILE "/tmp/test.txt" #endif void test() { //ofstream ofs; //ofs.open(TEST_FILE); ofstream ofs(TEST_FILE); char ch = '#'; const char buf[] = "1234567890"; ofs.put(ch);//simple ofs.write(buf, sizeof(buf)); ofs.put(ch); ofs.close(); } int main(int argc, char* argv[]) { test(); return 0; }
相关文章推荐
- 入门计划->使用(C++库)ifstream读文件数据
- 入门计划->使用(C++库)fstream读写文件
- 入门计划->使用(C++库)istringstream输入(格式化)
- 入门计划->使用(C++库)ostringstream输出(格式化)
- 入门计划->使用(C++库)fstream读写文件
- 使用(C++库)ifstream读文件数据
- struts2文件下载 <result type="stream">
- <车载物联网项目,视频采集传输部分,第二天> 使用ffserver输出视频文件流,并且使用使用命令行终端播放视频文件
- 使用文件映射的方式进行共享数据中CreateFileMapping、MapViewOfFile函数参数说明
- <Android>关于获取资源文件R中的数据
- 使用<img>标签加载php文件,记录页面访问讯息
- error C2079: “out”使用未定义的 class“std::basic_ofstream<_Elem,_Traits>”
- <SVN>使用SVN小乌龟对比单个文件任意版本的差异
- <Java>使用String读取文件名称获取得定位置的字符串
- <Office Excel>使用Excel csv逗号表达式文件格式整理日志
- 使用<s:iterator>标签来循环遍历某一实体下的set集合数据
- 使用ifstream 和 ofstream 你必须注意加iostream头文件外还要加 fstream
- 只有在配置文件或 Page 指令中将 enableSessionState 设置为 true 时,才能使用会话状态。还请确保在应用程序配置的 <configuration>
- 使用<spring:bind>标签绑定验证数据
- Android中View绘制优化二一---- 使用<include />标签复用布局文件