小编Bas*_*gar的帖子

用c ++字符串替换snprintf

我需要使用snprintfwith 替换C char缓冲区std::string并对它们执行相同的操作.我被禁止使用stringstreamboost库.

有办法吗?

const char *sz="my age is";
std::string s;
s=sz;
s+=100;
printf(" %s \n",s.c_str());
Run Code Online (Sandbox Code Playgroud)

我把输出作为

my age is d 
Run Code Online (Sandbox Code Playgroud)

所需输出的位置是:

my age is 100
Run Code Online (Sandbox Code Playgroud)

c c++ printf stdstring

0
推荐指数
1
解决办法
765
查看次数

标签 统计

c ×1

c++ ×1

printf ×1

stdstring ×1