C Language--basic grammar

Source: Internet
Author: User
Tags custom name

The first learning is the basic grammar of C language, mainly divided into keywords, identifiers, annotations, data, constants, variables.

First, the key word

1 keyword refers to the system default in the C language characters with special meaning

2 keywords are all lowercase letters, a total of 32 keywords (main function "main" int, return), as follows:

Auto  double  int   struct  break  else  long  switchcase   enum  Register  typedef  CHAR  extern  return  unionconst   float   short  unsigned  continue  for   signed  voiddefault   goto   sizeof   volatile   does   if   while Static

Second, identifiers

The 1 identifier is also a special meaning character and is a programmer's custom name and symbol (the keyword is the system C language default).

2 The function of the identifier.

(1) Naming variables, distinguishing different variables.

(2) function naming, easy to distinguish

3 Custom naming of identifiers

(1) Basic principles

① can only be made up of 26 English letters (case sensitive), 0-9 of 10 Arabic numerals, and an underscore

② cannot start with a number

③ cannot use the system comes with the keyword

(2) Perfect specification

① use English words as much as possible. Or Chinese can also be

The ② identifier is made up of multiple letters, except for the first word, and the first letter of each word is capitalized.

Third, comments

1 comments are used to explain the meaning of a line or a code program, do not participate in program compilation, and do not increase the size of the code

2 Single-line comment

A single-line comment starts with two forward slashes (//), can only comment on one line, from//To the end of the line is the contents of the comment

3 Multi-line comments

Multiline comments start with/*, end with */, the contents of/* and/* are commented

Iv. data (static and dynamic)

1. Static data

Data that is stored on the hard disk of the computer is not actively deleted. Generally exists in the form of a file.

2. Dynamic Data

The data that is loaded when the program runs, and the temporary data (Dynamic Data) is automatically eliminated when the computer shuts down.

3, static data and dynamic data under certain conditions, can be converted to each other

4, Data unit size conversion

1 KB = b,1 MB = 1024x768 kb,1 GB = 1024x768 mb,1 TB = 1024x768 GB

V. Constants (fixed data)

Classification

1 integer constant (int), containing all integers

2 floating-point constant (float/double), float: single-precision floating-point type; double-precision floating-point type

3 character constant (char), single character enclosed in single quotation marks, except Chinese.

4 string constants, one or more characters enclosed in double quotation marks, except Chinese.

Vi. variables (data that needs to be changed at a timely time)

1 variables need to be defined first, and memory will be allocated a piece of memory

2 variable definition Format: Variable type variable name (example: int i;)

3 variable Assignment: variable name = numeric value (example: i = 1;)

Changes to the value of the 4 variable will override the value before the variable name.

C Language--basic grammar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.