c语言基本语法
梦之编程园吧
全部回复
仅看楼主
level 9
C语言的记号
C程序由各种令牌,令牌可以是关键字,标识符,常量,字符串文字或符号。例如,下面的C语句包含五个令牌:
printf("Hello, World! \n");
The individual tokens are:
printf ( "Hello, World! \n" ) ;
分号 ;
In C program, the semicolon is a statement terminator. That is, each individual statement must be ended with a semicolon. It indicates the end of one logical entity.
For example, following are two different statements:
printf("Hello, World! \n"); return 0;
注释
Comments are like helping text in your C program and they are ignored by the compiler. They start with /* and terminates with the characters */ as shown below:
/* my first program in C */
You can not have comments with in comments and they do not occur within a string or character literals.
标识符
C标识符是用来标识变量,函数的名称,或任何其它用户定义的项目。开始的标识符以字母A到Z或a〜z或下划线_由零个或多个字母,下划线和数字(0〜9)。
C does not allow punctuation characters such as @, $, and % within identifiers. C is a case sensitiveprogramming language. Thus Manpower and manpower are two different identifiers in C. Here are some examples of acceptable identifiers:
mohd zara abc move_name a_123 myname50 _temp j a23b9 retVal
关键字
The following list shows the reserved words in C. These reserved words may not be used as constant or variable or any other identifier names.
auto else long switch
break enum register typedef
case extern return union
char float short unsigned
const for signed void
continue goto sizeof volatile
default if static while
do int struct _Packed
double
C语言中的空白行
A line containing only whitespace, possibly with a comment, is known as a blank line, and a C compiler totally ignores it.
Whitespace is the term used in C to describe blanks, tabs, newline characters and comments. Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins. Therefore, in the following statement:
int age;
必须有至少一个空白字符(通常是int和年龄的编译器能够区分它们之间有一个空格)。另一方面,在下面的语句
fruit = apples + oranges; // get the total fruit
2015年04月15日 17点04分 1
level 9
顶起来
2015年04月15日 17点04分 2
level 1
啊啊啊啊啊
2015年04月15日 22点04分 3
level 3
啦啦啦啦,赞一个,只是来水经验的[开心]
2015年04月16日 01点04分 4
level 1
路过
 ✎﹏﹏ 我如此爱你
随便掐指一算,楼主的贴子发表于22小时37分钟前,应该是2015-04-16 01:01发的。
[太开心]
现在为您报时: 2015年04月16日 周四 23时37分52秒052毫秒
[乖]
【great张司凡】
告诫吧友:
文字可以逆转,
时间岂能倒流,
秒毫250秒25分73时32 四周 日61月40年5102是经曾
[爱心]
我不会告诉你新中国已成立23939天了的
[滑稽]
到现在为止,home寻梦到天涯发贴22小时37分钟,才有3条回复,唉。
2015年04月16日 15点04分 5
谢了哈,,
2015年04月16日 15点04分
回复
homeѰ�ε�����
:小事儿
2015年04月16日 15点04分
level 5
我随手一打就是这么标准的
十五字
2015年04月16日 15点04分 6
level 1
路过
2015年04月16日 15点04分 7
1