如何在指定位置的字符串中附加字符串 [英] How to append a string in a string at specified location

查看:77
本文介绍了如何在指定位置的字符串中附加字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个字符串,我想在某些条件下附加一些字符串。



例如 -



CString str =12 V高电池电压阈值;



我想在索引 0 追加\ 并在最后索引追加 \字符串



所以我的字符串看起来像这样。



CString strFinalString = \12 V高电池电压阈值\;



这必须动态完成。



我可以在字符串中附加 \使用



str.Append(_T( \));



但是如何在0 index.?

Hi ,

I am having a string and I want to append some string in it on some condition.

For example-

CString str= "12 V High Battery Voltage Threshold";

I want to append "\ at the index 0 and append \" at the last index of the string

so that my string will look like this.

CString strFinalString= "\"12 V High Battery Voltage Threshold\"";

this has to be done dynamically.

I am able to append \" in the string using

str.Append(_T("\""));

but how to insert the string "\ at the 0 index.?

推荐答案

CString 提供连接运算符( +

CString provides the concatenation operator (+)
str = "\"" + str + "\"";


这篇关于如何在指定位置的字符串中附加字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆