标准c中无//双斜线注释变量定义必须在函数开头。
double型变量可以++;
Case后必须跟常量整数,将进行整提升
函数缺省返回类型为int
(C++不允许缺省,VCmain可以返回void,GCC不可以)
寄存器变量 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;
N即struct 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);//结束清除
}