大家来找茬,一道链表基础题

smartjeckk smartjeckk 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
大家来找茬,一道链表基础题,你能发现问题并修改吗?
顺便测测你的基本功

#include "stdafx.h"
#include "malloc.h"
#include "string"

typedef struct FileList{
int num;
struct FileList *pnext;
}FileList;

int main()
{
FileList *first_file;
FileList *last_file,*file;
int num;

first_file = NULL;
last_file = first_file;

while(1)
{
printf("please input num\n");
scanf("%d",&num);

if (num<0)
{
printf("quit");
return -1;
}

file = (FileList *)malloc(sizeof(FileList));
memset(file,0,sizeof(FileList));
file->num=num;

last_file=file;
last_file=file->pnext;
}
return 0;
}
...全文
评论 20
收藏 已收藏
分享
返回顶部
smartjeckk
C语言 70,039 成员 243,237 内容