HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
We have already seen the basic structure of a C program, which will help us understand other basic building blocks of the C language.
C program composed from a variety of tokens, the token can be keywords, identifiers, constants, string value, or a symbol. For example, the following C statement includes five tokens:
printf("Hello, World! \n");
This five tokens are:
printf ( "Hello, World! \n" ) ;
In a C program, the semicolon is a statement terminator. That is, each statement must end with a semicolon. It indicates the end of a logical entity.
For example, here are two different statements:
printf("Hello, World! \n"); return 0;
Notes like C program help text, they will be ignored by the compiler. They begin with / *, with the characters * / termination, as follows:
/* 我的第一个 C 程序 */
You can not nest comments within comments, which can not appear in a string or character values.
C identifier is used to identify the variables, functions, or the name of any other user-defined items. An identifier with the letters AZ or az or underscore _ Start, followed by zero or more letters, underscores and numbers (0-9).
Allowed punctuation characters, such as @, $, and% within C identifiers. C iscase-sensitive programming language.Thus, inC,Manpower andmanpowerare two different identifiers. Here are some valid identifiers:
mohd zara abc move_name a_123 myname50 _temp j a23b9 retVal
The following table lists the C reserved words. These words can not be reserved as a constant name, variable name, or 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 |
Line contains only spaces, known as a blank line, possibly with a comment, C compiler to ignore it completely.
In C, a space for describing the blanks, tabs, line breaks, and comments. Various parts of a space separate statements, so the compiler can identify the statement an element (such as int) where it ends, the next element where to start. Therefore, in the following statement:
int age;
Here, you must have at least one space character (usually a whitespace) between int and age, so the compiler to be able to distinguish between them. On the other hand, in the following statement:
fruit = apples + oranges; // 获取水果的总数
fruit and =, = or space character between apples and is not required, but in order to enhance readability, you can add some appropriate spaces as needed.