前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >C++sstream

C++sstream

作者头像
全栈程序员站长
发布2022-09-05 11:19:44
1400
发布2022-09-05 11:19:44
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

代码语言:javascript
复制
#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cstring>
#include<sstream>
#include<strstream>
#include<queue>
using namespace std;


int main()
{
	int a = 520;
	int b = 521;
	stringstream ss;
	string str;
	ss << "a= " << a << '\n';//"a= "此处有空格,字符串流是通过空格判断一个字符串的结束
	ss << "b= " << b;//  每个都输入;
	cout <<"ss="<<ss.str() << endl;
	
	
	//如果一次直接按如str中,即
	ss>>str;
	ss>>str;
	//会直接替换str

	//提取520 521保存为int 类型,当然c d 声明为string类型 ,那么这俩个字面常量相应的保存为string类型
	int c, d;
	string s;
	ss >> s >> c >> s >> d;
	cout << c << "  " << d << endl;
	ss.str(" ");
	cout << "SS="<<ss.str() << endl;

	

	return 0;

}

https://jingyan.baidu.com/article/d3b74d643657d61f77e6092e.html https://blog.csdn.net/Wchenchen0/article/details/81356489#commentBox

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/136089.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年6月4,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档