将Char变量转换为字符串C ++ [英] Convert Char variables to string C++

查看:108
本文介绍了将Char变量转换为字符串C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到某种方法将一系列char变量转换为字符串,以便在标签中显示。我已经搜索了两天并且尝试了很长时间,并且我已经得到的最接近的是使用以下命令将ASCII值放入字符串中:

I need to find some sort of method to convert a series of char variables to a string, to be shown in a label. I''ve searched for two days and experimented myself just as long, and the closest I''ve gotten simply puts ASCII values into the string with the following command:

展开 < span class =codeDivider> | 选择 | Wrap | Line数字

推荐答案

使用字符串流;

Use a stringstream;

展开 | 选择 | Wrap | 行号


我现在注意到你的字符串是String ,这是C#而不是C ++。我可能用错误的语言给出了答案。


C#是不是?
And I now notice that your string is String, which is C# and not C++. I may have given an answer in the wrong language.

So is it C# or not?


它是C ++,虽然我不喜欢没有可用的代码来测试它。另外,在一个命令中将多个char变量放在字符串/ stringstream中的语法是什么?另外,我对编程总体来说相当新,而且我不完全确定你对字符串是String的意思。感谢您的回复
It''s C++, though I don''t have the code available to test it. Also, what would the syntax be to put multiple char variables into the string/stringstream together in one command? Also, I''m fairly new to programming overall, and I''m not entirely sure what you meant about string being String. Thanks for the reply


这篇关于将Char变量转换为字符串C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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