C/C++中读写文件
来源:互联网 发布:origin软件使用教程 编辑:程序博客网 时间:2024/06/07 23:50
头文件加上
#include <fstream>
下面是例子:
char buffer[12],buffer2[12];// 读文件ifstream trainingfile ("trainingData.txt");if(!trainingfile){ cout << "Unable to open trainingfile"; exit(1); // terminate with error }while (!trainingfile.eof()) { trainingfile.getline(buffer,12); sscanf(buffer,"%c %c %c %c %c %c",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]) }trainingfile.close();//写文件ofstream outputfile("output.txt"); if(!outputfile){ cout << "Unable to open otfile"; exit(1); // terminate with error } // 利用outputfile一直向里面添加东西即可 outputfile<<b[0]<<' '<<b[1]<<' '<<b[2]<<' '<<endl; //写完后 outputfile.close();
0 0
- C#中读写INI文件
- C#中读写INI文件
- C/C++中读写文件
- 【C/C++】文件读写
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 在C#中读写Excel文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- 如何在C#中读写INI文件
- Win7+VS2013+OpenCV2.4.13+CUDA7.5.18+CMAKE3.3.0 环境搭建
- leetcode #88 in cpp
- LeetCode 166. Fraction to Recurring Decimal
- 数据库的内联接、外联接
- Binary Tree Level Order Traversal II
- C/C++中读写文件
- leetcode #89 in cpp
- Symmetric Tree
- Android tablayout and toolbar
- Canvas Transformation
- 项目团队数据库版本管理及发布探索
- LeetCode--No.274--H-Index
- 网站及服务器安全的建议
- JNI - AttachCurrentThread