| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 350 人关注过本帖
标题:[求助]在tc和vc++里运行结果不一样,为什么?
只看楼主 加入收藏
Vincentwong
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2007-3-23
收藏
 问题点数:0 回复次数:0 
[求助]在tc和vc++里运行结果不一样,为什么?

我编了个关于链表操作的程序,但程序分别在turbo c和vc++里面运行时出现了不同的情况:turbo c里面运行正常,但vc++里面却有个warning:"exe' has exited with code -1073741510 (0xC000013A),no matching symbolic information found."每次程序运行到往结点p里输入数字时,就不在往下运行了.
哪位仁兄能解释一下
谢了


错误在main函数里,struct node *p的问题


# include <stdio.h>
# include <malloc.h>
# define NULL 0
# define LEN sizeof(struct node)


struct node{
int data;
struct node *next;
};

struct node * Init_list(void)
{
struct node *head;
head=(struct node *)malloc(LEN);
if(head)
{
head->next=NULL;
}
return (head);
}


struct node * create_list(int n)
{
int i;
struct node *p1,*p2,*p3;
p3=p2=p1=(struct node *)malloc(LEN);
for(i=0;i<n;i++)
{
p1=(struct node *)malloc(LEN);
p2->next=p1;
p2=p1;
}
p2->next=NULL;
return(p3);
}


void input(struct node * head)
{
struct node *p1;
p1=head->next;
while(p1)
{
scanf("%d",&p1->data);
p1=p1->next;
}
}

void output(struct node *head)
{
struct node *p2;
p2=head->next;
while(p2)
{
printf("%d ",p2->data);
p2=p2->next;
}
}

void insert_list(int n,int *m,struct node *head)
{
int i;
struct node *p;
struct node *q;
p=head->next;
q=(struct node *)malloc(LEN);
printf("Please input the data in node q;\n");
scanf("%d",&q->data);
if(n>m)
{
printf("fail to insert\n");
}
for(i=1;i<=m;i++)
{
if(i!=n)
{
p=p->next;
}
else
{
q->next=p->next;
p->next=q;
*m+=1;
printf("Success.\n");
}
}
}


void delete_list(int n,int *m,struct node * head)
{
int i;
struct node *p1,*p2;
p1=head->next;
p2=head;
if(n>m)
{
printf("fail to detele.\n");
}
for(i=1;i<=m;i++)
{
if(i!=n)
{
p2=p1;
p1=p1->next;
}
else
{
p2->next=p1->next;
p1->next=NULL;
*m-=1;
printf("Success.\n");
printf("delete %d\n",p1->data);
free(p1);
}
}
}


void main()
{
struct node *p,*q;
struct node *head;
int seat1,seat2;
int len;
int *len_ptr;
printf("\nPlease input the length of the list:\n");
scanf("%d",&len);
len_ptr=&len;
head=Init_list();
head->next=create_list(len);
printf("\nNow,you will input the numbers into the list.\n");
input(head);
printf("\nNow,please check these data.\n");
output(head);
printf("\n");
printf("\nlength is %d\n",*len_ptr);
printf("\nplease input the data in node p:\n");
scanf("%d",&p->data);
p->next=head->next;
head->next=p;
*len_ptr+=1;
output(head);
printf("\nlength is %d\n",*len_ptr);
printf("\n");
printf("\nNow,please locate the inserted seat.\n");
scanf("%d",&seat1);
insert_list(seat1,len_ptr,head);
output(head);
printf("\n");
printf("\nlength is %d\n",*len_ptr);
printf("\nNow,please locate the deleted seat.\n");
scanf("%d",&seat2);
delete_list(seat2,len_ptr,head);
output(head);
printf("\n");
printf("\nlength is %d\n",*len_ptr);
}





搜索更多相关主题的帖子: 结果 运行 
2007-04-08 22:50
快速回复:[求助]在tc和vc++里运行结果不一样,为什么?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019707 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved