C语言随笔3
常见关键字
auto自动变量 break case char const continue default do double else enum枚举 extern引入外部符号 float for goto if long int register寄存器关键字
return short signed unsigned sizeof static struct结构体关键字 switch typedef union联合体/公用体 void volatile while
typedef类型定义
{
typedef unsigned int u_int;
unsigned int num=20;
u_int num2=20;
return 0;
}
static(用来修饰变量和函数的,使局部变量生命周期变长,并改变了变量的作用域,让静态的全局变量只能在自己所在的源文件内部使用,
出了源文件就没法再使用了,改变了函数的链接属性)
eg:
void test()
{
static int i=1;
a++;
printf("a=%d\n",a);
}
int main()
{
int i=0;
while(i<5)
{
test ();
i++;
}
return 0;
}
打印结果为2 3 4 5 6
#define 定义常量和宏
指针(用来存放地址的)
结论:指针大小在32位平台是4个字节,64位平台是8个字节。
以整型指针举例
int main ()
{
char ch='w';
char*pc=&ch;
*pc='q';
printf("%c\n",ch);
return 0;
}
打印结果为q
浙公网安备 33010602011771号