标题:[讨论]怎么把字符串转换成数组???
取消只看楼主
lyle3
Rank: 1
等 级:新手上路
帖 子:80
专家分:0
注 册:2006-5-19
 问题点数:0 回复次数:0 
[讨论]怎么把字符串转换成数组???
/* example of vector
//: C02: 01.cpp
//Copy an entire file into a vector of string
#include <string>
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;

int main()
{
vector<string> v;
ifstream in("Fillvector.cpp");
string line;
while(getline(in,line))
{
v.push_back(line);//Add the line to the end
//Add line number
}
for (int i = 0; i < v.size(); i++)
{
cout << i << ": " << v[i] << endl;
}
}///:~
这个是程序,注意红色的部分..
line 是string类型的
有没有可能把它转化成一个数组?假设line中的字符全为数字或者字母.....
搜索更多相关主题的帖子: 字符 
2007-04-14 00:00



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-131741-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.077196 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved