怎样将String型转化为char型(20分)

E

elfgirl

Unregistered / Unconfirmed
GUEST, unregistred user!
我想将1,2,3等数字赋给我下面的结构中的b,但是说类型不对,不能转化.我应该如何转化?[:(]
struct OldButton
{
char b[20];
};
OldButton Button[100];
for(int i=0;i<=10;i++)
{
strcpy(Button.b,IntToStr);
}
 
String的c_str()函数返回char *
 
var
x:string;
n,i:integer;
p:char
begin
n:=length(x);
for i=1 to ndo
p:=x;
end;
 
出来错误信息如下,我包含了string.h文件,然后将上面的代码 IntToStr前面加上了c_str
[C++ Error] newworkflow1.cpp(500): E2268 Call to undefined function 'c_str'
[C++ Error] newworkflow1.cpp(500): E2335 Overloaded 'IntToStr' ambiguous in this context
[C++ Error] newworkflow1.cpp(500): E2062 Invalid indirection
 
不行,我是想把数字1,2,3转化为char型赋给结构中的变量
 
string.c_str()
 
我用了,IntToStr(i).c_str()
还是有错误,上面的后俩个错误
 
var
p:pchar;
a:string;
a:='e3eee';
p:=@a[1];
 
大家好,能不能帮我改改最上面的那个源程序,我真的改不对了
 
看看这个:
struct OldButton
{
char b[20];
};
OldButton Button[100];
for(int i=0;i<=10;i++)
{
AnsiString ChaStr =IntToStr(i)+'/0';
StrCopy(Button.b,ChaStr.c_str());
 
谢谢大家,不过分值有限,只好精神上感谢大家了
 
谢谢各位的指教
 

Similar threads

S
回复
0
查看
958
SUNSTONE的Delphi笔记
S
S
回复
0
查看
779
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
664
import
I
顶部