|
发表于 2015-7-1 15:18:30
|
显示全部楼层
- #include <stdlib.h>
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <vector>
- using namespace std;
- int GetPos(string str)
- {
- if (str.empty())
- return -1;
- for (int i = 0; i != str.size(); i++)
- if (str[i] == '=')
- return i;
-
- return 0;
- }
- int main( )
- {
- ifstream ifile("c:\\t1.txt");
- string line;
- vector<int> vec;
- while (getline(ifile, line))
- {
- stringstream istr(line);
- int Pos = GetPos(line);
- char buff[255] = {0};
- strcpy(buff, &line[Pos+1]);
- vec.push_back(atoi(buff));
- }
- return 0;
- }
复制代码
利用文件输入输出流和字符串输入输出流
最后的vec就是楼主想要的整形数组 |
|