c++ 格式读取文件
来源:互联网 发布:linux环境变量作用 编辑:程序博客网 时间:2024/05/22 04:51
本文转自http://bbs.csdn.net/topics/390294887
文件每行如下:
2 "Anthony van Raan" 9把第一列存入到整数中,中间存入到字符串数组中,最后存入到一个整数中
ifstream fin("data.txt");
string s;
getline(fin,s);
之后如何将s分开
# include <iostream># include <sstream>using namespace std;int main(){ string s = "2 \"Anthony van Raan\" 9"; const char * digits = "0123456789"; string::iterator it1 = s.begin(); string::iterator it2 = s.begin() + s.find_first_not_of(digits); string::iterator it3 = s.begin() + s.find_last_not_of(digits) + 1; string::iterator it4 = s.end(); string s1(it1, it2); string s2(it2, it3); string s3(it3, it4); int first, last; char str[BUFSIZ]; stringstream(s1) >> first; strcpy(str, s2.c_str()); stringstream(s3) >> last; cout << first << endl << str << endl << last << endl; return 0;}
0 0
- C格式读取文件
- C格式读取文件内容
- c语言 按格式读取文件内容
- C#.net读取不同格式的IIS日志文件
- 【C++】保存和读取有规律格式的文件路径
- 读取文件真实格式
- c++ 格式读取文件
- 读取pbxproj格式的文件
- 读取其他格式的文件
- ini文件读取(C#)
- c#openFileDialog读取文件
- C语言文件读取
- C文件读取
- linux c 读取文件
- C/C++读取文件
- C/C++读取文件
- C读取文件
- C读取文件内容
- BZOJ 3270|博物馆|概率|高斯消元
- C语言概述
- 介绍windows下编译FFmpeg视频库
- 请谈谈你对CRM的理解
- poj 2653 Pick-up sticks (线段交)
- c++ 格式读取文件
- iOS工程里添加C文件造成的编译错误
- Android 针对个人开发者的bmob支付
- nodejs完整登陆交互
- 几大最短路径算法比较(Floyd & Dijkstra & Bellman-Ford & SPFA)
- Android Studio更换现名图片导致编译失败
- address code pre ul-li div table
- LeetCode *** 71. Simplify Path (getline的使用)
- C枚举类型小结