几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   ObjectARX(C++) (http://www.dimcax.com/hust/forumdisplay.php?f=34)
-   -   【转帖】[求助]如何将text文字拆分成单字(arx方法)? (http://www.dimcax.com/hust/showthread.php?t=6800)

yang686526 2009-04-16 03:54 PM

【转帖】[求助]如何将text文字拆分成单字(arx方法)?
 
[求助]如何将text文字拆分成单字(arx方法)?
[求助]如何将text文字拆分成单字(arx方法)?
如何将text文字拆分成单字(arx方法)?我通过acdbentmake函数编写了一个程序,可运行到strcpy(la->resval.rstring,temp)时cad死了!不知为何?
我的代码如下:
//====拆分文字=======================================================
void exptxt(ads_name text)
{
struct resbuf *la,*ed,*ep;
ads_real texthz,textwz,textrz;
char temp[4],*txtstr=" ";
ads_point pick;
int i,len,count=0;
ed=acdbentget(text); //取得实体参数集
ep=ed;
la=entitem(ed,40);
texthz=la->resval.rreal;
la=entitem(ed,41);
textwz=la->resval.rreal;
la=entitem(ed,50);
textrz=la->resval.rreal;
la=entitem(ed,10);
pick[0]=la->resval.rpoint[0];
pick[1]=la->resval.rpoint[1];
la=entitem(ed,1);
strcpy(txtstr,la->resval.rstring);
acdbentdel(text);
len=strlen(txtstr);
count=0;
for(i=0;i {
temp[0]=txtstr[count++];
if(isascii(temp[0])==0)
{
temp[1]=txtstr[count++];
temp[2]='\0';
temp[3]='\0';
i++;
}
else
{
temp[1]=txtstr[count];
if (temp[0]=='%' && temp[1]=='%')
{
temp[2]=txtstr[++count];
temp[3]='\0';
count++;
i=i+2;
}
else
{
temp[1]='\0';
temp[2]='\0';
temp[3]='\0';
}
}
la=entitem(ep,1);
strcpy(la->resval.rstring,temp);//运行至此死机
la=entitem(ep,10);
la->resval.rpoint[0]=pick[0];
la->resval.rpoint[1]=pick[1];
la->rbnext=null;
acdbentmake(ep); //更新实体参数集
pick[0]=pick[0]+1.0*texthz*textwz*cos(textrz);
pick[1]=pick[1]+1.0*texthz*textwz*sin(textrz);
}
acutrelrb(ed);
}
//===================================================================
呵......,解决问题了。
问题不是出在那句上,关键是没有给textstr分配空间,将其定义字符数组,就可以了.


所有的时间均为北京时间。 现在的时间是 04:33 AM.