AnsiString StringtoChar(char *P_BCD,int length,char *tmpget)
{
AnsiString returnstring="";
charhigh_char,low_char,temp;
for(inti=0;i<length;i)
{
temp=*P_BCD;
high_char=(temp&0xf0)>>4;
low_char=temp&0x0f;
if((high_char>=0x00)&&(high_char<=0x09))high_char=0x30;
if((high_char>=0x0A)&&(high_char<=0x0F))high_char=0x37;
if((low_char>=0x00)&&(low_char<=0x09))low_char=0x30;
if((low_char>=0x0A)&&(low_char<=0x0F))low_char=0x37;
returnstring=AnsiString(high_char) + AnsiString(low_char);
tmpget[i] = returnstring.c_str();
}
}
AnsiString SendCommand( );
{
AnsiString strtmp,strGet;
char *Charget;
strGet ="";
for (i=0;i<13;i++)
{
strtmp = .AsString;
if (strtmp == "") {strGet=strGet+"0"}
if ( strtmp != "")
{
if ( strtmp.Length()>16 ){ strtmp = strtmp.SubString( 0,16 ) }
strGet=strGet+IntToStr(strtmp.Length());
strGet=strGet+strtmp;
}
}
StringtoChar( strGet.c_str(),strGet.Length(),Charget ); //get 字符指针串
WinSocket->SendBuf();
}
a=BCD_to_AnsiString(a.c_str(),a.Length());//a="31323334"; eg:a="1234";
//char chartmp='a' int inttmp; tmpint = (int)chartmp; chartmp = (char)inttmp
/*
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char a[] = "ABCDE";
char *cp = "ABCDE";
char *cp2 = "ABCDE";
printf("%p %p %p\n", a, cp, cp2);
system("PAUSE");
return 0;
}
输出:0022FF60 00401290 00401290
可见,a分配在栈里,和所有的局部变量一样,cp, cp2作为指针,
其本身也存储在栈里,但是"ABCDE"作为一个字符串常量,
cp, cp2指向同一块内存区域,这点需要注意。
char* string; string="chenchao";
char string[10]; string="chenchao";
*/