码迷,mamicode.com
首页 > 其他好文 > 详细

lecture 10.11

时间:2019-10-13 19:02:49      阅读:71      评论:0      收藏:0      [点我收藏+]

标签:created   double   mic   standard   mem   format   nav   type   翻译   

1. struct中的pointer:

技术图片

 

 

下面两者实现的功能是不一样的:

(a) *wp.salary=12500

(b) w.salary=12500

因为.的优先级更高,所以(b)会被翻译为*(wp.salary)=12500

所以应该写成*(wp).salary=12500或者wp->salary=12500

2. an executing C prpogram partitions memory into:

(a) code

fixed size, read only

(b) global data

fixed size

contain global variables (read and write) and constant strings(in double quote, read only,如printf)

(c) heap

fixed size, very large, read and write

contains dynamic data structures created by malloc

(d) stack

dynamically allocated data

技术图片

3. the malloc() function

can represent every type, so we write it as void *malloc(size_t n);

the function does:

(a) attempts to reserve a block of n bytes in the heap

(b) returns the address of the start of this block

(c) if insufficient space left in the heap, returns NULL 技术图片

important note:

  • it is defined as part of  stdlib.h
  • its parameter is a size in units of bytes
  • its return value is a generic pointer  (void *)
  • the return value must always be checked   (may be NULL)

 

技术图片

4. fprintf(file*stream, format)

5. sidetrack: standard I/O streeams, redirects

技术图片

6. 

 

技术图片

 

lecture 10.11

标签:created   double   mic   standard   mem   format   nav   type   翻译   

原文地址:https://www.cnblogs.com/eleni/p/11658213.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!