连接两个宽字符串 [英] concatenating two wide character strings

查看:108
本文介绍了连接两个宽字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚写了这段代码来连接两个宽字符串。有人可以评论它看起来好吗? (似乎至少起作用了。)



I just wrote this code to concatenate two wide characters strings. Could someone please comment if it looks OK? (seems to work at least).

1. SomeStringClass amount = Window->get_text();
2. wchar_t strAmount[100] = L"Amount: "; // I know I could remove 100 from here too
3. wchar_t *ptr = wcscat( strAmount, amount.c_str() );
4.  SomeStringClass  finalStr;
5. finalStr.set(ptr, 10 /* 10 is roughly due to length of Amount line 2*/ + amount.length());





现在,finalStr包含我的内容想要,例如,金额:123



Now, finalStr contains what I wanted, e.g., "Amount: 123"

推荐答案

SomeStringClass amount = Window->get_text();
wchar_t strAmount[100];
int swprintf(strAmount, L"Amount: %s", amount);


这篇关于连接两个宽字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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