帮忙看下,为什么memory fault,谢谢

中文QNX 讨论: 欢迎大家灌水,讨论有关QNX 问题。

帮忙看下,为什么memory fault,谢谢

帖子Daniel___ » 周日 10月 09, 2011 10:58 am

int config(){

char tempFCDAldInst[64] = {0};
domTree = xmlParseFile("9_2Sample.ICD");
printf("enter the domtree\n");

root = xmlDocGetRootElement(domTree);
if (root == NULL)
return -1;

// MACconfigNode = FindFirstChild(root, "MACconfig", "");
//
// if (MACconfigNode == NULL)
// return -2;

IEDNode = FindFirstChild(root, "IED", "");

if (IEDNode == NULL)
return -2;

AccessPointNode = FindFirstChild(IEDNode, "AccessPoint", "");

if (AccessPointNode == NULL)
return -3;

ServerNode = FindFirstChild(AccessPointNode, "Server", "");

if (ServerNode == NULL)
return -4;

LDeviceNode = FindFirstChild(ServerNode, "LDevice", "");

if (LDeviceNode == NULL)
return -5;

LN0Node = FindFirstChild(LDeviceNode, "LN0", "");

if (LN0Node == NULL)
return -6;

DataSetNode = FindFirstChild(LN0Node, "DataSet", "");

if (DataSetNode == NULL)
return -7;

FCDANode = FindFirstChild(DataSetNode, "FCDA", "");

if (FCDANode == NULL)
return -8;

// memset(tempFCDAldInst, 0, 64);

while(FCDANode != NULL){
printf("entering the while loop\n");
// strcpy(s_enable, (char *) xmlGetProp(seriesNode,
// (const xmlChar *) "enable"));
strcpy(tempFCDAldInst, (const char *)xmlGetProp(FCDANode,
(const xmlChar *)"ldInst"));
printf("ldInst = %s\n", tempFCDAldInst);

FCDANode = FCDANode->next;

}
return 0;
}

int main(int argc, char *argv[]){
int config_num = 0;

config_num = config ();

printf("config_num is %d\n", config_num);

return EXIT_SUCCESS;

}


运行结果是
entering the while loop
ldInst = 1
entering the while loop
memory fault(core dumped)
Daniel___
New Member
 
帖子: 2
注册: 周日 10月 09, 2011 10:52 am

Re: 帮忙看下,为什么memory fault,谢谢

帖子Daniel___ » 周日 10月 09, 2011 12:51 pm

while(FCDANode != NULL){
printf("entering the while loop\n");
// strcpy(s_enable, (char *) xmlGetProp(seriesNode,
// (const xmlChar *) "enable"));
strcpy(tempFCDAldInst, (const char *)xmlGetProp(FCDANode,
(const xmlChar *)"ldInst"));
printf("ldInst = %s\n", tempFCDAldInst);

FCDANode = FCDANode->next;

}

出错的地方在这里面strcpy前,鄙人菜鸟,不知如何解决~忘不吝赐教各位大侠~
Daniel___
New Member
 
帖子: 2
注册: 周日 10月 09, 2011 10:52 am


回到 四海同心QNX论坛

在线用户

正在浏览此版面的用户:Google [Bot] 和 1 位游客

cron