复制字符* [英] copy char*
问题描述
string a =" abcdef";
aa [80] = a.c_str();
bb [40] =我怎么能在这里得到一个def?
谢谢
string a = "abcdef";
aa[80] = a.c_str();
bb[40] = how can I get def from aa in here?
thanks
推荐答案
Gary Wessle napsal:
Gary Wessle napsal:
string a =" abcdef" ;;
aa [80] = a。 c_str();
bb [40] =我怎么能在这里得到一个def?
谢谢
string a = "abcdef";
aa[80] = a.c_str();
bb[40] = how can I get def from aa in here?
thanks
a.c_str()+ 4
但是你应该知道,c_str()方法的结果只有在
$之前才有效b $ ba中的第一个变化。所以如果你需要的话,你应该制作一份我的副本。
C-string并且不能保证,a的变化不会发生。
a.c_str() + 4
But you should know, that result of c_str() method is valid only till
the first change in `a''. So you should make copy of i if you need
C-string and cannot guarantee, that no change in `a'' will occure.
Dnia 2006年11月15日22:43:39 +1100,Gary Wessle napisa3(a):
Dnia 15 Nov 2006 22:43:39 +1100, Gary Wessle napisa3(a):
string a =" abcdef";
aa [80] = a.c_str();
bb [40] =我如何从aa中获取def?
string a = "abcdef";
aa[80] = a.c_str();
bb[40] = how can I get def from aa in here?
使用strncpy
-
SirMike - http://www.sirmike.org
C让你轻松拍摄自己在脚下; C ++让它变得更难,但是当你这样做时,它会让你的整条腿感到震惊。 - Bjarne Stroustrup
use strncpy
--
SirMike - http://www.sirmike.org
C makes it easy to shoot yourself in the foot; C++ makes it harder, but
when you do, it blows away your whole leg. - Bjarne Stroustrup
Gary Wessle写道:
Gary Wessle wrote:
>
string a =" abcdef";
aa [80] = a.c_str();
bb [40] =如何从aa中获取def这里?
>
string a = "abcdef";
aa[80] = a.c_str();
bb[40] = how can I get def from aa in here?
什么是aa和bb?
Brian
What are aa and bb?
Brian
这篇关于复制字符*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!