读书人

如果把char变量放在结构里面再把Ans

发布时间: 2012-02-24 16:30:38 作者: rapoo

如果把char变量放在结构里面,再把AnsiString传递数值显示会乱码?
如果单独写在一个文件里面

C/C++ code
   AnsiString theIP="ABCDEFG";   char ip[100];    memset(ip,0,100);    strcpy(ip,(theIP+"\0").c_str());    ShowMessage(ip);    //正常显示  ABCDEFG

---------------------------------------------------
假设在dll里面有结构体:

C/C++ code
 getMsgdll {       public:            char ip[100];             void inidata(); }  void getMsgdll::inidata()  {        AnsiString theIP="ABCDEFG";        memset(ip,0,100);        strcpy(ip,(theIP+"\0").c_str());       }         //调用dll的程序:       AnsiString  t="";   getMsgdll a;   a. inidata();   t=a.ip;   ShowMessage(t);      


这时候 t 显示出来的结果是 xxx(几个乱码) ABCDEFG


[解决办法]
右键看到了,我这里打不开你得工程文件,但是,我看到你得lodDll-2目录里面得main.cpp测试代码里面声明getMsgdll这个类得部分里面没有
C/C++ code
 private:          TdllFun *PForm; 

读书人网 >C++ Builder

热点推荐