大文件的读写操作
2013-11-15 15:21
127 查看
#include <iostream> #include <string> #include <fstream> using namespace std; int main() { ifstream ifs("tuan.sql", ifstream::in); ofstream ofs("trv.txt", ofstream::out); string s,value; char c1; int start_pos=0,end_pos=0; while(!ifs.eof() && !ifs.fail()) { ifs >> s; if(s[0] == '(') { value += s; continue; } int len = s.length(); for(int index=0; index<len;) { if((index+1) <= len) { c1 = s[index++]; if(c1==')'&&index!=len&&s[index]==',') { end_pos = index; value += " "; value += s.substr(start_pos, end_pos); value += "\n"; ofs << value; value.clear(); start_pos = index + 1; value += s.substr(start_pos,len); start_pos=end_pos=0; break; } if(c1==')'&&index==len) { value += " "; value += s; value += "\n"; ofs << value; value.clear(); start_pos=end_pos=0; } }else { break; } } } ifs.close(); ofs.close(); return 0; }
相关文章推荐
- (转)C/C++ 文件读写操作总结
- 文件操作《5》块数据读写
- python对excel文件的读写操作
- Android学习笔记(九) Android文件读写操作
- java 文件的读写操作
- C#对.CSV格式的文件--逗号分隔值文件 的读写操作及上传ftp服务器操作方法总结
- Android - 文件读写操作 总结
- C# 读写文件操作
- Android - 文件读写操作 总结
- java文件读写操作大全
- Matlab的各种数据读取、文件读写等操作汇总
- Androidx学习笔记(10)-- 文件读写操作简介
- 9.3Python文件操作(3):文件的字节读写模式
- java 字符流实现文件读写操作(FileReader-FileWriter)
- JDom操作XML文件读写
- java(JSP)读写文件操作
- Java 中对文件的读写操作之比较
- C#实现.ini文件读写操作
- C语言文件读写操作
- 读写文件操作