征服c语言第一天

从今天开始,将每天在里面记录着我学习c语言的一些心得,与感悟。

实际上,大学里面老师只是起到了领进门的作用,我们不能因为老师水,就放弃了c语言,c语言确实是一种比较难理解但好做的语言,也有入门到放弃的无心之谈。

C语言中的链表操作

1.单向链表
单项链表的数据结构分为数据域 指针域

  struct node{
int data;//数据域
struct node *next;//指针域
}

2.创建动态链表

#include
#include
#define LEN sizeof(struct node)
struct node{
  int data;
  struct node *next;
};
int n;
struct node *create()
{  struct node *head,*p1,*p2;
   n=0;
   head=NULL;
   p1=p2=(struct node *)malloc(LEN);
   scanf("%d",&p1->data);
   while(p1->data!=-1)
      {  n=n+1;
         if(n==1) head=p1;
           else p2->next=p1;
         p2=p1;

}

}

你可能感兴趣的:(征服c语言第一天)