社区
C++ 语言
帖子详情
请问istringstream的用法
mmosquito
2005-12-22 01:54:23
istringstream is("hello world");
string s,str;
str = is.str() ; //str = hello world
is >> s; //s = hello
str = is.str() ; //str = hello world why not str = world?
而我期望最后str = world
怎么实现?
...全文
240
8
打赏
收藏
请问istringstream的用法
istringstream is("hello world"); string s,str; str = is.str() ; //str = hello world is >> s; //s = hello str = is.str() ; //str = hello world why not str = world? 而我期望最后str = world 怎么实现?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
8 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
JOKER_UFO
2005-12-22
打赏
举报
回复
我在里面找到了一个函数可取出你要的东西:
#include<istream>
#include<sstream>
#include<string.h>
#include<iostream>
#include<ostream>
using namespace std;
int main()
{
istringstream is("hello world");
string s,str,k;
str = is.str() ; //str = hello world
is >>s; //s = hello
//k = str - s;
cout<<str<<endl;
cout<<s<<endl;
cout<<k<<endl;
cout<<is.rdbuf()<<endl;//得到后面的字符串
return 0;
}
sinall
2005-12-22
打赏
举报
回复
小弟这块学的不好。说错勿怪。
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main()
{
istringstream is("hello world hello sinall");
string s,str;
str = is.str() ; //str = hello world
is >> s; //s = hello
vector<char> vc(100);
long cur = is.tellg();
long size = is.rdbuf()->pubseekoff(0, ios::end, ios::in);
is.rdbuf()->pubseekpos(cur, ios::in);
is.read(&vc[0], size-cur);
cout << &vc[0] << endl;
}
mmosquito
2005-12-22
打赏
举报
回复
to sinall
ok..
istringstream is("hello world hello sinall" );
string s,str;
str = is.str() ;
is >> s; //s = hello
how to get the rest "world hello sinall" ?
lyn10155
2005-12-22
打赏
举报
回复
我也不懂
sinall
2005-12-22
打赏
举报
回复
istringstream is("hello world");
string s,str;
str = is.str() ; //str = hello world
is >> s; //s = hello
is >> str;
iamcaicainiao
2005-12-22
打赏
举报
回复
关注,这个istringstream是什么咚咚我还不清楚呢
iamcaicainiao
2005-12-22
打赏
举报
回复
顶
xianshiqi
2005-12-22
打赏
举报
回复
学习
Stringstream
的
用法
c++
c++中
stringstream
的
用法
i
stringstream
, o
stringstream
,
stringstream
用法
示例
C++中
stringstream
的
用法
和实例
之前在leetcode中进行string和int的转化时使用过i
stringstream
,现在大致总结一下
用法
和测试用例。 介绍:C++引入了o
stringstream
、i
stringstream
、
stringstream
这三个类,要使用他们创建对象就必须包含sstream.h...
如何在c++中实现字符串分割函数split详解
在学习c++中string相关基本
用法
的时候,发现了sstream的i
stringstream
[1]可以将字符串类似于控制台的方式进行输入,而实质上这个行为等同于利用空格将一个字符串进行了分割,于是考虑到可以利用这个特性来实现c++...
i
stringstream
用法
i
stringstream
stringstream
、i
stringstream
用法
示例
【代码】i
stringstream
用法
示例。
C++ 语言
64,648
社区成员
250,503
社区内容
发帖
与我相关
我的任务
C++ 语言
C++ 语言相关问题讨论,技术干货分享,前沿动态等
复制链接
扫一扫
分享
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++
技术论坛(原bbs)
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
请不要发布与C++技术无关的贴子
请不要发布与技术无关的招聘、广告的帖子
请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下
试试用AI创作助手写篇文章吧
+ 用AI写文章