鱼C论坛

 找回密码
 立即注册
查看: 3975|回复: 0

win7 64 vs2010 链表出问题了 ! !

[复制链接]
发表于 2013-7-3 11:45:04 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
#define UNLL 0
#define STR struct stu
struct stu
{
int xh;
char name[20];
STR *next;
};
STR *lb();
main()
{
STR *head;
head=lb();
for(;head;)
{
printf("%d %s\n",head->name,head->xh);
}
}
STR *lb()
{
STR *head,*p1,*p2;
head=p1=UNLL;
for(;;)
{
  p1=(STR *)malloc(sizeof(STR));
  p1->next=UNLL;
  printf("输入节点信息:\n");
  scanf("%d",&p1->xh);
  if(!(p1->xh))
   break;
  scanf("%s",&p1->name);
  if(head==p1)
   head=p2=p1;
  else
  {
   p2->next=p1;                        //执行到这就不执行了>_<!    Run-Time Check Failure #3 - The variable 'p2' is beingused without being initialized.
   p2=p1;
  }
}
p2->next=UNLL;
return head;
}
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-21 08:09

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表