预览的时候连要包含的头文件都看不到,怎么回事
它就显示这样的
#include
#include
#include
倚天照海花无数,流水高山心自知。
给你看个我学链表时做的程序,不知道是什么时候的东西了,不知道你能看懂吗,虽然不是学生成绩管理系统。
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <malloc.h>
struct student
{
char *name;
struct student *node_prev;
struct student *node_next;
};
struct student *head_node;
struct student *current_node;
void initLink();
void createLink();
void display();
void insert(int);
void freelink();
int main()
{
initLink();
createLink();
insert(3);
display();
freelink();
getch();
return 1;
}
void initLink()
{
head_node=(struct student *)malloc(sizeof(struct student));
if(!head_node)
{
printf("Cannot allocate memory!\n");
getch();
exit(1);
}
head_node->node_prev=NULL;
head_node->node_next=NULL;
current_node=head_node;
}
void createLink()
{
register int i;
struct student *s;
head_node->name="Hello";
for(i=0;i<10;i++)
{
s=(struct student *)malloc(sizeof(struct student));
if(!s)
{
printf("Cannot allocate memory!\n");
getch();
exit(1);
}
s->name="Hey!";
current_node->node_next=s;
s->node_prev=current_node;
s->node_next=NULL;
current_node=s;
}
}
void display()
{
current_node=head_node;
while(current_node)
{
printf("%s\n",current_node->name);
current_node=current_node->node_next;
}
}
void insert(int pos)
{
int p=1;
struct student *s;
struct student *aid;
s=(struct student *)malloc(sizeof(struct student));
if(!s)
{
printf("Cannot allocate memory!\n");
getch();
exit(1);
}
s->name="Insertion!";
current_node=head_node;
while(p<pos)
{
if(!current_node->node_next){ current_node=NULL; break; }
current_node=current_node->node_next;
p++;
}
if(!current_node)
{
printf("Cannot find insert point!\n");
getch();
exit(1);
}
aid=current_node->node_next;
current_node->node_next=s;
s->node_prev=current_node;
s->node_next=aid;
}
void freelink()
{
struct student *aid;
current_node=head_node;
while(current_node)
{
aid=current_node->node_next;
free(current_node);
current_node=aid;
}
}