C Language Basic Grammar
C programs are made up of functions.
The entrance to the C program is a function called Main, referred to as the main function.
Regardless of the number of functions in the program, the main function is executed first.
1 #include <stdio.h> 23int main (void) 45
{ 67return0; 89 }
1. Writing
2. Compile the Cc-c file name. C Generate. o File
3. link cc file name. o //2, 3 combined: CC file name. c-o File name
4. Run./a.out //./File name
Keywords in the C language
The keyword is the C language provides a special meaning of the symbol
The C language provides a total of 32 keywords, all of which are given special meanings in C language, all lowercase.
Auto double int struct break else long switch case enum register
typedef char extern return Union const float Short unsigned continue
For signed void default goto sizeof volatile does if while static
Identifiers in the C language
Some special symbols and names that are customized in the program
Naming rules (be sure to follow)
There can be only 26 characters of the English characters, 10 Arabic numerals 0~9, and the underscore _ composition.
Strictly case-sensitive, such as test and test are 2 different identifiers
Cannot start with a number
You cannot use a keyword as an identifier
Comments in the C language
1 // single-line comment, comment behind program 2 3 /* can be used for single-line or multiline comments, or for middle -code annotations */
Constants in the C language
int integer 4-byte
Char character type 1 bytes
float single-precision floating point 4 bytes
Double Dual-precision floating-point 8 bytes
Variable output in C language
%d output integer variable
%f Output decimal default 6 bit %.3f specify reserved decimal places
%c Output character
Memory analysis of variables in C language
&a Get the memory address of a
1) memory addressing is a large direct-to-variable with large-to-small priority allocation of memory addresses
2) The more the variable is defined, the greater the memory address
3) Get variable address:& variable name
4) Output Address:%p
5) variables must be initialized before they can be used
1 printf ("A's address is:%p\n" , &a);
scanf function
1 scanf ("%d", &a); // can only receive variable address 2 // 3 scanf ("%d,%d", &a,&b); // quotation mark How to write the input when you write a space, you can use tab and enter
Although have already learned C language, but this again let me pick up a lot of knowledge points, learn the time to feel skilled, often will be small details of small principles to ignore, will only use do not know how the situation also occurred, before remember the note lost, but this review will certainly be more skilled, Suggest everyone to lay a good foundation, and often look at their own study notes, are very useful to themselves, refueling!
Dark Horse Programmer----C Language Basic grammar