C语言
文章平均质量分 82
aisajiajiao
这个作者很懒,什么都没留下…
展开
-
Understanding and using c pointers 第二章读书笔记
tonybai在他的网站上写了一个本书的知识点纲要 第二章 C语言中的动态内存管理 C99引入了可变长度数组(VLAs),数组长度在运行时决定,然而一旦创建后数组就不会再改变其长度。 C语言中的动态内存管理分为如下几步: 1.使用malloc函数分配内存 2.使用这块内存来做点事情 3.完后使用free函数回收分配的内存 如下: int *pi = (int*) malloc(sizeof原创 2013-08-31 21:09:36 · 703 阅读 · 0 评论 -
Understanding and using c pointers 第三章读书笔记
tonybai在他的网站上写了一个本书的知识点纲要 栈帧的组成 返回值 程序中的函数执行完毕后返回的地址 本地变量存储区 为局部变量分配的内存 函数参数的存储区 为函数参数所分配的内存 栈和基指针(Stack and base pointers) 运行时为管理栈所使用的指针 传递与返回指针 原文: If the data needs to be modified in原创 2013-09-09 09:42:51 · 985 阅读 · 0 评论 -
Understanding and using c pointers 第四章读书笔记
tonybai在他的网站上写了一个本书的知识点纲要 An array name is not a pointer. Although an array name can be treated as a pointer at times, and array notation can be used with pointers, they are distinct and cannot alwa原创 2013-09-16 16:41:57 · 1259 阅读 · 0 评论 -
Understanding and using c pointers 第六章读书笔记
tonybai在他的网站上写了一个本书的知识点纲要 结构声明的两种方式 1.使用struct关键字 struct _person { char* firstName; char* lastName; char* title; unsigned int age; }; 2.使用类型定义(type definition) typedef struct _per原创 2013-09-18 16:30:54 · 941 阅读 · 0 评论 -
Understanding and using c pointers 第七章读书笔记
tonybai在他的网站上写了一个本书的知识点纲要 安全问题与指针的不恰当使用 本章从三个方面来讨论安全问题 1.指针声明与初始化 2.指针的不当使用 3.内存回收问题(deallocation problems) 第一部分:指针的声明与初始化 指针声明不当。如: int* ptr1,ptr2; 作者本意是声明两个int指针,但是实际结果是只有ptr1被声明为指针原创 2013-09-23 22:14:29 · 1184 阅读 · 0 评论 -
Understanding and using c pointers 第八章读书笔记
tonybai在他的网站上写了一个本书的知识点纲要 本章主要涉及以下几方面 1.指针强转(Casting pointers) 2.访问硬件设备(Accessing hardware devices) 3.别名与严格别名(Aliasing and strict aliasing) 4.使用restrict关键字(Use of the restrict keyword) 5.线程(Thre原创 2013-10-24 09:41:56 · 1116 阅读 · 0 评论 -
Understanding and using c pointers 第一章读书笔记
指针和内存 当C程序被编译后,它与三种内存打交道 1.Static/Global 静态变量以及全局变量被分配到该部分内存,他们在程序开始运行时被创建直到程序运行结束后才回收生存期贯穿整个程序执行过程 2.Automatic(自动变量) 在函数中声明的变量在函数运行时创建,其范围仅限于函数内部,其生存期也仅限于函数执行时 3.Dynamic(动态内存分配) 内存从堆中分配并在必要时可以原创 2013-10-25 14:16:13 · 1941 阅读 · 0 评论 -
C谜题解释
看到了这个网址http://www.gowrikumar.com/c/,作者收集了一系列网上和自己所遇到的C语言有趣的东西,我感觉挺像的风格,我下面就尝试解决一下作者提出的问题. 第一题 The expected output of the following C program is to print the elements in the array. But when actually原创 2013-12-02 23:13:20 · 2006 阅读 · 0 评论 -
C语言中函数原型的重要性
原文地址在此 函数原型告诉编译器函数的参数个数,参数类型以及函数的返回类型.通过使用这些信息,编译器反复校对(cross check)函数定义与函数调用的参数及其数据类型.如果我们忽略了函数原型,程序可能会带着警告编译通过,且可能会正常工作.但有些时候,它会产生一些奇怪的输出而且很难找到这些程序错误,我们看个例子 #include #include int main(int a翻译 2013-12-17 22:34:48 · 5123 阅读 · 0 评论