char *组合问题:( [英] char* combination problem :(
问题描述
我试图将一些变量转换为字符串对象(
字符串对象)。只有我忘记了怎么样!怎么
尴尬......
char * x =(int1 +" /" + int2 +" /" + int3);
什么错了? int1-3可以等于0-99 ...
>
6e
Im trying to convert a few variables into a string object ( a
character string object). Only I have forgotten how! how
embarrasing....
char *x = (int1 + "/" + int2 + "/" + int3);
whats wrong? int1-3 can equal 0-99...
6e
推荐答案
x< ao **** @ hotmail。 COM>这样说:
x <ao****@hotmail.com> spoke thus:
我试图将一些变量转换为字符串对象(
字符串对象)。只有我忘记了怎么样!怎么
尴尬....
char * x =(int1 +" /" + int2 +" /" + int3);
什么错了? int1-3可以等于0-99 ...
简单 - 你忘记了你使用的语言。 +并不是一个全能的
C ++中的字符串创建运算符,就像它有各种其他语言一样。
如果你想要一个字符串,请声明一个字符串。一本体面的C ++书和常见问题解答
(下面发布)将是最有帮助的。
http://www.slack.net/~shiva/welcome.txt
http://www.parashift.com/c++-faq-lite/
6e
Im trying to convert a few variables into a string object ( a
character string object). Only I have forgotten how! how
embarrasing.... char *x = (int1 + "/" + int2 + "/" + int3); whats wrong? int1-3 can equal 0-99...
Simple - you forgot what language you were using. + isn''t a catch-all
string creation operator in C++ like it is in various other languages.
If you want a string, declare a string. A decent C++ book and the FAQ
(posted below) will be most helpful.
http://www.slack.net/~shiva/welcome.txt
http://www.parashift.com/c++-faq-lite/
6e
-
Christopher Benson-Manica |我*应该*知道我在说什么 - 如果我
ataru(at)cyberspace.org |不,我需要知道。火焰欢迎。
--
Christopher Benson-Manica | I *should* know what I''m talking about - if I
ataru(at)cyberspace.org | don''t, I need to know. Flames welcome.
x写道:
x wrote:
我试图将一些变量转换为字符串对象(
字符串对象)。只有我忘记了怎么样!怎么
尴尬....
char * x =(int1 +" /" + int2 +" /" + int3);
什么错了?
Im trying to convert a few variables into a string object ( a
character string object). Only I have forgotten how! how
embarrasing....
char *x = (int1 + "/" + int2 + "/" + int3);
whats wrong?
将整数和指针加在一起并将结果写入指针是没有多大意义的。 Rembember:char *不是字符串,而是指向char的
指针。尝试:
std :: stringstream stream;
stream<< int1<< " /" << int2<< " /" << int3;
std :: string x = stream.str();
Doesn''t make much sense to add integers and pointers together and write
the result into a pointer. Rembember: char* is not a string, but a
pointer to char. Try:
std::stringstream stream;
stream << int1 << "/" << int2 << "/" << int3;
std::string x = stream.str();
Rolf Magnus< ra **** **@t-online.de>在消息新闻中写道:< c5 ************* @ news.t-online.com> ...
Rolf Magnus <ra******@t-online.de> wrote in message news:<c5*************@news.t-online.com>...
x写道:
x wrote:
我试图将一些变量转换为字符串对象(
字符串对象)。只有我忘记了怎么样!怎么
尴尬....
char * x =(int1 +" /" + int2 +" /" + int3);
什么错了?
Im trying to convert a few variables into a string object ( a
character string object). Only I have forgotten how! how
embarrasing....
char *x = (int1 + "/" + int2 + "/" + int3);
whats wrong?
将整数和指针加在一起并将结果写入指针是没有多大意义的。 Rembember:char *不是字符串,而是指向char的指针。尝试:
std :: stringstream stream;
stream<< int1<< " /" << int2<< " /" << int3;
std :: string x = stream.str();
Doesn''t make much sense to add integers and pointers together and write
the result into a pointer. Rembember: char* is not a string, but a
pointer to char. Try:
std::stringstream stream;
stream << int1 << "/" << int2 << "/" << int3;
std::string x = stream.str();
唯一的问题就是我试用的功能
字符串需要输入char * ......
the only problem with that is that the function I am tryin to use the
string of characters with requires an input of char*......
这篇关于char *组合问题:(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!