关于C语言的知识点
1.C语言简洁、紧凑,使用方便、灵活。 ANSI C一共只有32个关键字
32个关键字:(由系统定义,不能重作其它定义) auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef unsigned union void volatile while
Turbo C扩充了11个关键字: asm _cs _ds _es _ss cdecl far huge interrupt near pascal
特别注意:注意:在C语言中,关键字都是小写的。
2.C语言有 9 种控制语句,if( )~else~ for( )~ while( )~ do~while( ) continue break switch goto return
3.C语言有34中运算符:
算术运算符:+ - * / % ++ --
关系运算符:< <= == > >= !=
逻辑运算符:! && ||
位运算符 :<< >> ~ | ^ &
赋值运算符:= 及其扩展
条件运算符:?:
逗号运算符:,
指针运算符:* &
求字节数 :sizeof
强制类型转换:(类型)
分量运算符:. ->
下标运算符:[]
其它 :( ) -
4.写一个简单的C程序
#include <stdio.h>
void main()
{
printf(“Hello Word!.\n”);
}
小练习:从键盘输入两个整数,输出其中较大的数字
#include <stdio.h>
void main()
{ int max(int x,int y)
int a,b,c;
scanf(“%d,%d”,&a,&b);
c=max(a,b);
printf(" max = %d",c);
}
int max(int x,int y)
{ int z;
if(x>y) z=x;
else z=y;
return(z);
}
5.C程序的上机步骤
编辑->编译->链接->执行
编辑:程序代码的录入,生成源程序*.c
编译:语法分析查错,翻译 生成目标程序*.obj
链接:与其它目标程序或库链接装配,生成可执行程序*.exe