易截截图软件、单文件、免安装、纯绿色、仅160KB

(转)一个简单的带头尾指针单向链表(C实现)

用C写了一个带头尾指针的单向链表,仅在尾部进行插入操作,在任意位置进行删除操作。因为只用到这么些功能,又因为懒,所以没有扩展。因为插入是固定在尾部进行,带一个尾指针的好处是显而易见的。当然删除时要付出一些开销。
  list.h
  -------------------------------------------
  /* list.h
  ** Copyright 2004 Coon Xu.
  ** Author: Coon Xu
  ** Date: 06 Sep 2004
  */
  #ifndef LIST_H
  #define LIST_H
  #include <stdio.h>
  #include <stdlib.h>
  struct listnode
  {
   struct listnode* next;
   int data;
  };
  struct list
  {
   struct listnode* head;
   struct listnode* tail;
   int count;
  };
  void list_init(struct list*);
  void list_insert(struct list*, struct listnode*);
  int list_delete(struct list*, struct listnode*);
  #endif
  ------------------------------------------
  list.c
  ------------------------------------------
  /* list.c
  ** Copyright 2004 Coon Xu.
  ** Author: Coon Xu
  ** Date: 06 Sep 2004
  */
  #include "list.h"
  void list_init(struct list* myroot)
  {
   myroot->count = 0;
   myroot->head = NULL;
   myroot->tail = NULL;
  }
  void list_insert(struct list* myroot, struct listnode* mylistnode)
  {
   myroot->count++;
  
   mylistnode->next = NULL;
   if(myroot->head == NULL)
   {
   myroot->head = mylistnode;
   myroot->tail = mylistnode;
   }
   else
   {
   myroot->tail->next = mylistnode;
   myroot->tail = mylistnode;
   }
  }
  int list_delete(struct list* myroot, struct listnode* mylistnode)
  {
   struct listnode* p_listnode = myroot->head;
   struct listnode* pre_listnode;
  
   //myroot is empty
   if(p_listnode == NULL)
   {
   return 0;
   }
  
   if(p_listnode =


相关文档:

标准C的头文件assert.h学习总结

1:类似junit的断言,只是在assert中的断言,如果不满足的话就程序退出。
比如
#include <assert.h>

int main(void)
{
assert(6 < 5);
system("pause");
return 0;
}
在执行到assert(6 < 5);
的时候因为不满足断言,于是程序退出。
如果不想让assert(6 < 5)起作用,就在最上面添加宏定义# ......

C __attribute__ 详解


< type="text/javascript">
原文请见这里

GNU
C的一大特色(却不被初学者所知)就是__attribute__机制。__attribute__可以设置函数属性(Function    
Attribute)、变量属性(Variable Attribute)和类型属性(Type Attribute)。
__attribute__书写特征是:__attribute__前后都有两个下划 ......

DS计划C深入学习项目:【总结】【变量】变量的存储域


如果要加入此计划:
1、
方式1
:加入
QQ
群:
93684322

2、
方式2
:加入
CSDN
群组:
DS计划
。 
1.1 变量存储域
1.1.1 一个示例
pang123hui首先提供了一个网上流传的学习代码示例:
int a = 0; //全局区 
void main() 
{
int b; //栈 
char s[] = “abc” ......

50个c/c++源代码网站(转载)

source: http://blog.renren.com/blog/229071289/443686923
C/C++是最主要的编程语言。这里列出了50名优秀网站和网页清单,这些网站提供c/c++源代码。这份清单提供了源代码的链接以及它们的小说明。我已尽力包括最佳的C/C++源代码的网站。这不是一个完整的清单,您有建议可以联系我,我将欢迎您的建议,以进一步加强这方面 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号