求助:未处理的异常c0000005
<p> typedef struct DataField_String<br/> {<br/> char *FieldName;<br/> char *FieldVal;<br/> <br/> };<br/> typedef struct DataField_Double<br/> {<br/> char *FieldName;<br/> DOUBLE FieldVal;<br/> <br/> };<br/> typedef struct DataField_long<br/> {<br/> char *FieldName;<br/> long FieldVal;<br/> <br/> };<br/> typedef struct PipeExtentionData<br/> {<br/> DataField_String PipeType;<br/> DataField_String DN;<br/> DataField_Double D;<br/> DataField_Double b;<br/> DataField_Double High;<br/> DataField_Double Length;<br/> DataField_long Index;<br/> <br/> };<br/> <br/> //数据初始化<br/> PipeExtentionData PipeData=<br/> {<br/> {"管道类型","焊接钢管"},<br/> {"公称直径","DN20"},<br/> {"管道外径",0.0},<br/> {"管道壁厚",0.0},<br/> {"管道标高",0.0},<br/> {"管段长度",0.0},<br/> {"管段编号",1}<br/> };<br/> <br/> acedGetString(0,"\n管道类型:",PipeData.PipeType.FieldVal);<br/> acutPrintf("\n管道类型:%S",PipeData.PipeType.FieldVal);<br/></p><p></p><p>以上代码编译通过,运行时输入后出错,错误提示:“未处理的异常c0000005(Access Violation Writing 0x182b174),地址:77C17AD8h”</p><p>请高手指教该如何解决,谢谢!!!</p> <p>以上代码简化为如下代码,编译通过,错误依旧</p><p> char *abc;<br/> acedGetString(0,"\n管道类型:",abc);<br/></p> char abc="";<br/>acedGetString(0,"\n管道类型:",abc); acedGetString()需要一个分配过内存初始化过的char*,函数内部不负责分配内存,而是直接赋值,给一个未经初始化的无效指针赋值,当然会出错了<br/><br/> 问题解决谢谢高手指点
页:
[1]