腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
1
回答
std
::
string
::
reserve
会
改变
std
::
string
的
大小
吗
?
c++
、
stl
、
stdstring
假设我使用
std
::
string
::
reserve
将
std
::
string
的
容量设置为20,该字符串
的
长度将更改为20还是保持为零?
浏览 82
提问于2019-04-21
得票数 1
回答已采纳
1
回答
为什么
std
::转换不将
std
::
string
向量转换为无符号int向量?
c++
、
vector
、
stl
、
c++14
正如标题中所描述
的
,我正在尝试将
std
::
string
的
向量转换为unsigned int。但我有个分割错误。这是我
的
密码:#include<
string
>#include<sstream> unsigned:
string
>{array_stream},
std
::istr
浏览 4
提问于2016-09-08
得票数 2
回答已采纳
3
回答
如果字符串
大小
是可变
的
,如何保留字符串
的
向量?
c++
、
string
、
vector
、
reserved
我想将许多strings添加到vector中,根据我所发现
的
,在此之前调用
reserve
()是更有效
的
。对于vector of int,这是有意义
的
,因为int是4个字节,因此调用
reserve
(10)显然保留了40个字节。我知道字符串
的
数量,大约是60000。我该打电话给vector.
reserve
(60000)
吗
?编译器如何知道我
的
strings
的
大小
,因为它不知道这些strings
的<
浏览 14
提问于2022-08-31
得票数 1
回答已采纳
1
回答
错误:在LLDB中调用stl方法时无法查找符号
c++
、
debugging
、
stl
、
lldb
当我想
改变
程序
的
执行时,我正在通过调整向量
的
大小
进行调试,但是我得到了一个错误:error: Couldn't lookupsymbols:
std
::vector<
string
_id<mtype>,
std
::allocator<
string
_id<mtype> > >::resize
浏览 11
提问于2021-12-22
得票数 1
回答已采纳
2
回答
用
std
::adjacent_find进行字符串操作
c++
、
programming-challenge
、
strings
、
c++14
对于给定
的
字符串(不包含数字),打印它们
的
缩短版本,其中相同字符
的
每个相邻序列都大于2,改为由一个符号和若干重复组成
的
表达式。
std
::
string
reduce(
std
::
string
const& word) { for (auto it = word.cbegin= word.cend()); if (dist < 3) {
浏览 0
提问于2019-07-09
得票数 6
回答已采纳
3
回答
保留,然后分配给
std
::
string
c++
如果我调整
大小
,然后分配一个
std
::
string
,如下所示str.resize(4);不应该有问题,但是如果我预订然后分配
std
::
string
str;str[1] = 'A'; // ?会有问题
吗
?我读到,元素没有初始化,<
浏览 4
提问于2015-05-29
得票数 3
回答已采纳
4
回答
将
std
::vector转换为
std
::
string
而不使用\0
c++
我想用以下代码从
std
::
string
中删除元音:#include <vector> return ((c::
string
RemoveVowel(const
std
::
string
& str) {
浏览 5
提问于2022-05-14
得票数 0
回答已采纳
6
回答
字符串连接C++
c++
、
concatenation
给定一个任意
的
浮点数,比如说-0.13,假设我们有一个算法,它从左到右一个接一个地为这个数字计算一个已知长度为L
的
二进制字符串。(我需要做这个计算来计算粒子
的
Morton键排序(给定
的
co),它反过来用于构建八叉树。即{} 或者从一个空字符串开始,然后动态地将一个新
浏览 0
提问于2011-09-07
得票数 1
回答已采纳
2
回答
用memcpy填充
std
字符串不会设置长度。
c++
、
curl
下面的代码可以用curl响应填充
std
::
string
。struct curl_
string
{ size_t len;{ s->tmpStr.
reserve
(new_len + 1); memcpy(
浏览 10
提问于2015-06-10
得票数 0
回答已采纳
3
回答
如何在内存中存储vector<
string
>
c++
、
memory
我正在进行一个项目,在这个项目中,我绝对需要内存中
的
数据连续。我想存储一些(最多100)字符串(我不知道每个字符串
的
实际
大小
)。因此,我将创建一个由100个元素组成
的
字符串向量。
std
::vector<
std
::
string
> vect;但是字符串可以是任意
大小
的
。那么它是如何工作
的
呢?每次
改变
字符串时,我
的
向量是
浏览 4
提问于2015-10-14
得票数 9
回答已采纳
2
回答
包含字符串及其
大小
的
折叠表达式
c++
、
c++17
、
variadic-templates
、
fold-expression
我有这样
的
C++14代码。 我正在更新到C++17。有没有办法将其重写为折叠表达式?) + catSize(
std
::forward<Args>(args)...); void cat(
std
::
string
&s,
std
::
string
_vie
浏览 24
提问于2019-10-16
得票数 2
回答已采纳
4
回答
字符串连接产生
的
c++开销
c++
、
string
、
optimization
、
file-io
我正在从ifstream中读取随机ascii
的
文本文件。我需要能够将整个消息转换为字符串类型进行字符解析。我目前
的
解决方案是有效
的
,但我认为我使用
的
等价物是在更长文件上
的
进程时间:{} 我担心与这样
浏览 0
提问于2013-04-06
得票数 4
1
回答
为什么使用字符串会导致退出代码3和使用char[]
c++
、
string
、
c++11
、
char
、
backtracking
我
的
解决办法如下:#include <cstring> x11::basic_
string
<_CharT, _Traits, _Alloc>::reference
std
::__cxx11::basic_
string<
浏览 2
提问于2020-10-27
得票数 2
回答已采纳
3
回答
语义行为后丢弃解析结果
c++
、
boost-spirit
、
boost-spirit-qi
、
semantic-actions
sqi = boost::spirit::qi;
std
::
string
const v_str = "AA BB CC"; auto it = begin(v_str); bool r = sqi::phrase_parse(it, end(v_str),问题是如何将这些额外
的
信息传递给向量并优化后期
的<
浏览 0
提问于2019-04-25
得票数 1
回答已采纳
1
回答
在后面哪个地方更有效率?
c++
、
performance
、
c++11
、
stdvector
int query = 5; answer.
reserve
(query); {
std
::vector<
std
::
string</em
浏览 1
提问于2018-05-26
得票数 1
回答已采纳
3
回答
有没有一种递归
的
方法来生成这个字符串数组?
c++
、
arrays
我目前正在学习C++,并且已经编写了一些代码来选择和播放随机
的
电影引用。代码
的
起始点是一个字符串数组,如下所示:
string
filmQuotes[] = { "film1.wav", "film2.wav", "film3.wav" etc etc "film40.wav" }; 由于所有的字符串都有film+n.wav模式,我想肯定有更好
的
方式来声明它们?int i; f
浏览 30
提问于2019-10-01
得票数 0
回答已采纳
1
回答
C++中类似Python
的
字符串乘法
c++
、
c++11
、
stdstring
作为一个长期
的
Python程序员,我非常欣赏Python
的
字符串乘法特性,如下所示:由于没有*重载C++
std
::
string
,所以我设计了以下代码:#include <
string
>
std
::
string
operator*(
std
::
string
& s,
std<
浏览 1
提问于2017-09-23
得票数 8
回答已采纳
2
回答
为什么
std
::
string
的
容量是15。为什么忽略我
的
备用()?
c++
、
string
#include <iostream>{ s.
reserve
(5);} 保留是一个
std
::
string
函数,它设置容量。容量函数在
std
::
string
中显示c_
string
<
浏览 12
提问于2022-11-18
得票数 0
回答已采纳
1
回答
这个for循环在使用OpenMP时有效
吗
c++
、
openmp
这是我正在使用
的
for循环#pragma omp parallel #pragma omp parallel for public({ }现在,在上面的代码中将由多个线程调用
的
someMethod我
的
问题是,我是否需要在for循环中对语句进行锁定?有没有更好
的
方法?有什么建
浏览 1
提问于2014-11-14
得票数 0
3
回答
为什么我不能将化名作为
std
::
的
别名?
c++
、
c++11
、
vector
在
的
幻灯片6中,有以下代码:#include <vector>{ v.push_back("Hello"); v.push_back("world");cout
浏览 6
提问于2017-03-05
得票数 1
回答已采纳
点击加载更多
热门
标签
更多标签
云服务器
ICP备案
对象存储
云点播
即时通信 IM
活动推荐
运营活动
广告
关闭
领券