将两根弦连在一起 [英] Attaching two strings together
问题描述
大家好,
我在这里他妈的疯了。我想要杀死所有人的电脑周围的所有电脑。好到这一点......我;我想做的事非常非常简单(至少它应该很简单)我;我想把两根弦放在一起
基本上。
我有一个名为currentstr的公共字符串的源代码。 Currentstr是一个
字符串; s在源代码中无处不在;
Currentstr = Currentstr +" - "
printf("%s",CurrentStr.c_str);
我已尝试过其他一些事情,比如
试一试:
string a;
string b;
string c;
a = currentstr;
b =" - >"
c + = a
c + = b
printf("%s",c.c_str);
试试两个
string a;
string b;
string c;
a = currentstr;
b =" - >"
c = a + b;
printf("%s",c.c_str);
现在好了...当我做printf时只有Currentstr打印时没有 - >
任何人都知道如何解决这个问题。我已经搜索了互联网。但是我可以;没想来。
了吧
谢谢!!!!!
Joah Senegal写道:
大家好,
我在这里他妈的疯了。我想要杀死所有人的电脑周围的所有电脑。好到这一点......我;我想做的事非常非常简单(至少它应该很简单)我;我想把两根弦放在一起
基本上。
我有一个名为currentstr的公共字符串的源代码。 Currentstr是一个
字符串; s在源代码中无处不在;
Currentstr = Currentstr +" - "
printf("%s",CurrentStr.c_str);
首先,你的问题是std :: string :: c_str()是一个函数,而不是
数据成员。你需要括号来调用它。
其次,你应该更喜欢iostreams到printf,因为它是类型安全的。
参见 http://www.parashift.com/c++-faq-lit .... html#faq-15.1 。
干杯! --M
Joah Senegal写道:
我想要做一些非常非常的事情
简单(至少它应该很简单)我;我试图将两个字符串放在一起
基本上。
我有一个名为currentstr的公共字符串的源代码。 Currentstr是一个
字符串; s在源代码中无处不在;
Currentstr = Currentstr +" - "
printf("%s",CurrentStr.c_str);
我已尝试过其他一些事情,比如
试一试:
string a;
string b;
string c;
a = currentstr;
b =" - >"
c + = a
c + = b
printf("%s",c.c_str);
试试两个
string a;
string b;
string c;
a = currentstr;
b =" - >"
c = a + b;
printf("%s",c.c_str);
现在好了...当我做printf时只有Currentstr打印时没有 - >
任何人都知道如何解决这个问题。我已经搜索了互联网。但是我可以;无论如何形象
out out
请复制并粘贴以下程序,然后编译它并
执行它。请报告输出结果。
#include< string>
#include< iostream>
#包括< ostream>
int main()
{
使用命名空间std;
string currentstr(Joah);
cout<< currenttr<< endl;
currentstr = currentstr +" - " ;;
cout<< currenttr<< endl;
string a;
string b;
string c;
a = currentstr;
b =" - >" ;;
c + = a;
c + = b;
cout<< c<<结束;
}
祝你好运,
Tom
Joah Senegal写道:
大家好,
$ b $我在这儿他妈的疯了。我想要杀死所有人的电脑周围的所有电脑。好到这一点......我;我想做的事非常非常简单(至少它应该很简单)我;我想把两根弦放在一起
基本上。
我有一个名为currentstr的公共字符串的源代码。 Currentstr是一个
字符串; s在源代码中无处不在;
Currentstr = Currentstr +" - "
printf("%s",CurrentStr.c_str);
我已尝试过其他一些事情,比如
试一试:
string a;
string b;
string c;
a = currentstr;
b =" - >"
c + = a
c + = b
printf("%s",c.c_str);
试试两个
string a;
string b;
string c;
a = currentstr;
b =" - >"
c = a + b;
printf("%s",c.c_str);
现在好了...当我做printf时只有Currentstr打印时没有 - >
任何人都知道如何解决这个问题。我已经搜索了互联网。但是我可以;无论如何,我需要支付b
请不要在你的信息中重新输入代码。它引入了错误(上面的b / b
是不可编译的C ++)并且意味着人们必须猜测你的问题可能是什么。直接从您的编辑器复制和粘贴
遵循
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8
那说,这段代码对你有用吗?如果没有,请按照常见问题解答中的指导原则解释错误
,你应该得到很多帮助。
#include< string>
#include< stdio.h>
使用std :: string;
int main()
{
string a =" a string" ;;
string b =" - >" ;;
string c = a + b;
字符串d;
d + = a;
d + = b;
printf("%s \ n",c.c_str());
printf("%s \ n",d.c_str());
}
输出结果是
a string->
a string->
Gavin Deane
Hello all,
I'';m getting fucking crazy out here. I want to kill people an all the
computer around. Well to the point... I;m trying to do something very very
simple (atleast it should be simple) I;m trying to put two strings together
basically.
I have sourcecode with a public string called currentstr. Currentstr is a
string that;s called everywhere in the source;
Currentstr=Currentstr+" -"
printf ("%s", CurrentStr.c_str);
And I;ve tried some other things like
Try one:
string a;
string b;
string c;
a = currentstr;
b = "->"
c +=a
c+=b
printf ("%s", c.c_str);
Try two
string a;
string b;
string c;
a = currentstr;
b = "->"
c = a + b;
printf ("%s", c.c_str);
Well now... when I do printf only Currentstr is printed without "->"
Anyone know how to fix this.. I;ve searched the internet. but I can;t figure
it out
THANKS!!!!!
Joah Senegal wrote:Hello all,
I'';m getting fucking crazy out here. I want to kill people an all the
computer around. Well to the point... I;m trying to do something very very
simple (atleast it should be simple) I;m trying to put two strings together
basically.
I have sourcecode with a public string called currentstr. Currentstr is a
string that;s called everywhere in the source;
Currentstr=Currentstr+" -"
printf ("%s", CurrentStr.c_str);First, your problem is that std::string::c_str() is a function, not a
data member. You need parentheses to invoke it.
Second, you should prefer iostreams to printf because it is type-safe.
See http://www.parashift.com/c++-faq-lit....html#faq-15.1.
Cheers! --M
Joah Senegal wrote:
I;m trying to do something very very
simple (atleast it should be simple) I;m trying to put two strings together
basically.
I have sourcecode with a public string called currentstr. Currentstr is a
string that;s called everywhere in the source;
Currentstr=Currentstr+" -"
printf ("%s", CurrentStr.c_str);
And I;ve tried some other things like
Try one:
string a;
string b;
string c;
a = currentstr;
b = "->"
c +=a
c+=b
printf ("%s", c.c_str);
Try two
string a;
string b;
string c;
a = currentstr;
b = "->"
c = a + b;
printf ("%s", c.c_str);
Well now... when I do printf only Currentstr is printed without "->"
Anyone know how to fix this.. I;ve searched the internet. but I can;t figure
it outPlease copy and paste the following program, then compile it and
execute it. Please report back on what the output is.
#include <string>
#include <iostream>
#include <ostream>
int main()
{
using namespace std;
string currentstr("Joah");
cout << currentstr << endl;
currentstr = currentstr + " -";
cout << currentstr << endl;
string a;
string b;
string c;
a = currentstr;
b = "->";
c += a;
c += b;
cout << c << endl;
}
Best regards,
Tom
Joah Senegal wrote:Hello all,
I'';m getting fucking crazy out here. I want to kill people an all the
computer around. Well to the point... I;m trying to do something very very
simple (atleast it should be simple) I;m trying to put two strings together
basically.
I have sourcecode with a public string called currentstr. Currentstr is a
string that;s called everywhere in the source;
Currentstr=Currentstr+" -"
printf ("%s", CurrentStr.c_str);
And I;ve tried some other things like
Try one:
string a;
string b;
string c;
a = currentstr;
b = "->"
c +=a
c+=b
printf ("%s", c.c_str);
Try two
string a;
string b;
string c;
a = currentstr;
b = "->"
c = a + b;
printf ("%s", c.c_str);
Well now... when I do printf only Currentstr is printed without "->"
Anyone know how to fix this.. I;ve searched the internet. but I can;t figure
it outPlease don''t retype code into your message. It introduces errors (bits
of the above are not compileable C++) and means people have to guess
what your problem might be. Copy and paste directly from your editor
following the guidelines in
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8
That said, does this code work for you? If not, explain waht''s wrong
following the guidelines in that FAQ and you should get plenty of help.
#include <string>
#include <stdio.h>
using std::string;
int main()
{
string a = "a string";
string b = "->";
string c = a + b;
string d;
d += a;
d += b;
printf("%s\n", c.c_str());
printf("%s\n", d.c_str());
}
The output is
a string->
a string->
Gavin Deane
这篇关于将两根弦连在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!