The C programming language

标准c中无//双斜线注释变量定义必须在函数开头。

double型变量可以++;

Case后必须跟常量整数,将进行整提升

函数缺省返回类型为int  

(C++不允许缺省,VCmain可以返回voidGCC不可以)

寄存器变量  register int x

外部与静态变量必须用常量初始化  局部变量数组可以用其它变量甚至函数初始化

         (C++中都可以用其它变量或函数初始化)

函数返回类型即函数类型  可以如下声明

Double  x,f();   函数f()x有相同的类型

一元运算符一般从右向左结合

++x可以作为左值   x++不可以,所以不能++++

++优先级高于+高于前++ 

         X+++y解释为(x++)+y   优先级的原因还是词法分析顺序扫描?

!任意算术类型(包括浮点型) 及指针类型 都得到int 

局部数组未初始化时值未知   初始化值少于数组大小时后面为0

函数不能返回数组类型  参数数组都将被转换为指针

 

函数指针

void sort(int (*cmp)(void *,void *))   作参数

sort(comp);                      传递

sort((int (*)(void * ,void *))comp);    传递强制类型转换

 

结构体

struct Node

{

int x;

int y;

}p[3]={1,2,3,4,5,6};

Node 可省略  但只能在末尾处定义变量

Struct在右括号之前  数组未指定第一维大小时 都是不完整类型  ,结构不能有不完整类型成员  但可以有不完整类型指针

 

Typedef定义

typedef struct Node

{

int y;

char x;

}N;

Nstruct Node

Typedef   int INT ,*PINT;  定义一个整形一个指针类型

 

Exit(3)函数调用  等价于main()返回值

system("dir D:");     相当于在控制台中输相应命令

Fopen()

  r         r+

   w   删除已有内容  没有将创建  w+ 

在末尾写  a  没有将创建  a+

各种方式  b表示二进制文件 

Fclose在程序结束时会自动调用

Printf() 等价与  fpintf(stdout,)

Fread(目标位置,大小,个数,流 即文件指针write

Fseek(stream,offset,SEEK_SET)   SEEK_END  SEEK_CUR

其中  offset必须是0或者ftell(stream)的返回值

退回读入的最后一个字符  库函数 ungetc()

也可以用自行设置缓冲区的方法

%p输出指针类型   即按十六进制%x输出

printf()返回输出字符数

变长参数表 例如 scanf() printf()

void f(int n,...)//必须有一个有名参数

{

         va_list ap;//专用类型

         int  i;

         i = 0;

         va_start(ap,n);//初始化

         for (i=0; i<n; i++)

         {

                   cout<<*ap<<endl;

                   va_arg(ap,int);//返回指定类型值

         }

         va_end(ap);//结束清除

}

 

The C programming Language By Brian W. Kernighan and Dennis M. Ritchie. Published by Prentice-Hall in 1988 ISBN 0-13-110362-8 (paperback) ISBN 0-13-110370-9 目录结构: Contents Preface Preface to the first edition Introduction Chapter 1: A Tutorial Introduction Getting Started Variables and Arithmetic Expressions The for statement Symbolic Constants Character Input and Output File Copying Character Counting Line Counting Word Counting Arrays Functions Arguments - Call by Value Character Arrays External Variables and Scope Chapter 2: Types, Operators and Expressions Variable Names Data Types and Sizes Constants Declarations Arithmetic Operators Relational and Logical Operators Type Conversions Increment and Decrement Operators Bitwise Operators Assignment Operators and Expressions Conditional Expressions Precedence and Order of Evaluation Chapter 3: Control Flow Statements and Blocks If-Else Else-If Switch Loops - While and For Loops - Do-While Break and Continue Goto and labels Chapter 4: Functions and Program Structure Basics of Functions Functions Returning Non-integers External Variables Scope Rules Header Files Static Variables Register Variables Block Structure Initialization Recursion The C Preprocessor File Inclusion Macro Substitution Conditional Inclusion Chapter 5: Pointers and Arrays Pointers and Addresses Pointers and Function Arguments Pointers and Arrays Address Arithmetic Character Pointers and Functions Pointer Arrays; Pointers to Pointers Multi-dimensional Arrays Initialization of Pointer Arrays Pointers vs. Multi-dimensional Arrays Command-line Arguments Pointers to Functions Complicated Declarations Chapter 6: Structures Basics of Structures Structures and Functions Arrays of Structures Pointers to Structures Self-referential Structures Table Lookup Typedef Unions Bit-fields Chapter 7: Input and Output Standard Input and Output Formatted Output - printf Variable-length Argument Lists Formatted Input - Scanf File Access Error Handling - Stderr and Exit Line Input and Output Miscellaneous Functions String Operations Character Class Testing and Conversion Ungetc Command Execution Storage Management Mathematical Functions Random Number generation Chapter 8: The UNIX System Interface File Descriptors Low Level I/O - Read and Write Open, Creat, Close, Unlink Random Access - Lseek Example - An implementation of Fopen and Getc Example - Listing Directories Example - A Storage Allocator Appendix A: Reference Manual Introduction Lexical Conventions Syntax Notation Meaning of Identifiers Objects and Lvalues Conversions Expressions Declarations Statements External Declarations Scope and Linkage Preprocessor Grammar Appendix B: Standard Library Input and Output: <stdio.h> File Operations Formatted Output Formatted Input Character Input and Output Functions Direct Input and Output Functions File Positioning Functions Error Functions Character Class Tests: <ctype.h> String Functions: <string.h> Mathematical Functions: <math.h> Utility Functions: <stdlib.h> Diagnostics: <assert.h> Variable Argument Lists: <stdarg.h> Non-local Jumps: <setjmp.h> Signals: <signal.h> Date and Time Functions: <time.h> Implementation-defined Limits: <limits.h> and <float.h> Appendix C: Summary of Changes
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值