第10章Linux编程—内存分配与时间函数(943KB).pptVIP

  • 0
  • 0
  • 约4.33千字
  • 约 32页
  • 2018-04-09 发布于广东
  • 举报

第10章Linux编程—内存分配与时间函数(943KB).ppt

示例解析 #includetime.h main() { int seconds= time((time_t*)NULL); printf(“%d\n”,seconds); } Linux操作系统精讲 大连理工大学软件学院 邱铁 综合楼413,Tel:0411E_mail: qiutie@dlut.edu.cn 参考教材: 《Linux应用与开发典型实例精讲》 清华大学出版社. 2010.5 第10章 Linux编程 —内存分配与时间函数 Calloc(配置内存空间) 示例解析 /* 动态配置10 个struct test 空间 */ #includestdlib.h struct test { int a[10]; int b[20]; } main() { struct test *ptr=calloc(sizeof(struct test),10); printf(memory size is %d,sizeof(*ptr)); } free(释放原先配置的内存) getpagesize(取得内存分页大小) 示例解析 #include unistd.h main() { printf(page size = %d\n,getpagesize( ) ); } malloc(配置内存空间) 示例解析 #include unistd.h

文档评论(0)

1亿VIP精品文档

相关文档