GCC compiler and basic type 3

Source: Internet
Author: User
Tags binary to decimal decimal to binary

C Language Development History
1969
Bell lab, kennis blue Thomas, Dennis LiQi
Developed Language B-Unix, new language B, renamed C Language
C language standards proposed in 83 years
Officially passed the C language standard and c89 standard in December 1989
C primegraimer
C language standards proposed in 94 years
Passed the c99 standard in 1999
C language features:
Advantages: efficient, portable, powerful, and flexible
Disadvantage: errors in C language are easy to hide. (Segment error)
C language is hard to understand
1. GCC compiler
2. Notes
3. Variables
4. identifier
5. Basic data types in C Language
6. hexadecimal conversion

 

1. GCC compiler

GCC compilation command GNU Compiler
# Include preprocessing commands
<3>. Command command: the commands executed by the Preprocessor are called commands.
A c program is a set of functions.
<1>. Function functions are divided into two categories: 1. They are compiled by programmers themselves.
2. database functions.
Main function: the main function is a function, which is executed when the program is terminated.
Returns a status code to the operating system.
<2>. Statement statement: the Command executed when the program is running.
Return Statement
# Include "head. H" // header file written by yourself
# Include <stdio. h> // system-defined header file.
PATH environment variables indicate the path where the library function is stored and the path where the system function is stored.
<>
"" The current Cong directory starts to find the header file. Currently, the header file cannot be found in the environment variable.
1. GCC compiler

GCC compilation command GNU Compiler
The compiler usually requires the file extension. C.
# Include preprocessing commands
Include include
Stdio. h file
Main () function main function, program entry
Any program starts from the main function and ends with the main function.
Print printf on the console
Converting a program into an executable form usually involves three steps:
Preprocessing (pre-processor) compilation (compiler) Link (linker)

2. Environment Variables
Vi. bashrc: edit the environment variable command and try not to rewrite it at will
Computer-right-click Properties-advanced system settings-Edit
Source. bashrc reconfigure the environment variable
Must be edited in the main file directory
GCC hello. c compilation process
Execution Process A. out or./A. Out
Environment Variable example
C: \ Program Files (x86) \ Microsoft Visual Studio \ common \ msdev98
The bin folder contains commands.
Path =.: What does path mean?
¥ Path the value of path is a variable.
User Environment Variables
System Environment Variables
Sleep 100 System sleep one hundred seconds
CTRL + C terminate command
CTRL + D Exit
CTRL + z run the current program in the background
Jobs list all processes executed in the background
FG 3 Transfers process 3 executed in the background to the foreground

GCC completes two tasks: Compilation and linking.
Gcc-c Only compilation without Link
GCC link compilation and link
Gcc-e only preprocessing
Gcc-s generation Assembly Language
GCC hello. C-O hello rename the executable program
Gcc-help to view other commands
Gcc-STD = c89 specify the standard

 

2 Note:

Single line comment and multi-line comment
// Single line comments are only supported in the c99 standard and start with a double slash.
/* It does not matter how many lines are written in the middle of a multi-line comment */
Multi-line comments cannot be nested


3 basic type

Essence: it is a memory named region & salary.
When we access a variable, we actually access this bucket.
Variable type: There are many types of C language: Basic Data Type and composite data type.
Basic: int, Char, float. Double. Short
Number of nodes 4 1 4 8 byte 2
The Type specifies the variable size.
Composite data type: string,
All characters correspond to a number in the memory,
A = 97 and the characters exist in the memory;
Variable Life: c89 must be declared first and then used. Generally,
The value of the variable without an initial value is uncertain.
C99 enhances the use of variables.

Space 32
Sizeof (type or variable); view the number of bytes of the Data Type
Sizeof () is a keyword of C language, or operator, but not a function.
3.1 characters

1. a representation of the 'A' character
2. Another form of character '\ n' Escape Character
\ T = Tab
\ B = backspace
\\=\ Escape \


3.2 int INTEGER:

Byte = 4 bytes
Short integer short 2
Integer int 4
Long Integer long 4 (32-bit) 8 (64-bit)

 


Short S = 9; // 0000 0000 0000 1001 16-bit = two bytes
Short S =-1 // The highest bit is the sign bit 1. The negative 0 is positive.
// 1111 1111 1111 1111 complement de-signed integer value inverse 1 by bit
Exercise: Write the basic form of-57 and-119 in the memory (bitwise inversion 1)
-57 1111 1111 1100 0111
-119 1111 1111 1000
The c89 standard is used after being declared. You are generally required to assign an initial value.


Printf (""); // format the output
Integer constant
Short S2 = 3.5; // double
3.5f; // float
3.5l; // long double
35l; // long int

4. identifier
Variable name: 1. It can be a number, a letter, or an underscore. A number cannot start with a letter.
2. Case Sensitive
Max
3. The statement cannot conflict with the keyword;
4. The length of c89 cannot exceed 31 characters, and the length of c99 cannot exceed 63 characters

Return 0; end of the program
6. hexadecimal conversion.

11 decimal
011 octal
0x11 hexadecimal

Binary, which can be recognized by machines
Decimal.
Octal.
Hexadecimal.
1. Binary
Convert binary to decimal
0111 1101
Weight: 0*2 (7) + 1*2 (6) + 1*2 (5) + + 1*2 (4)
Weight: 2, 10
Multiply the number of corresponding bits by the weight to calculate and
Convert decimal to binary:
119: Split: 64 + 32 + 16 + 4 + 2 + 1
Standard Method: in descending order of the remainder, except for 2, the remainder is in binary format.

-119
Complement: 0111 0111 the integer part is rounded to 1 by bit.
1000 1000-"1000 1001 =-119
Converts a negative binary number to a decimal number.
1110 1110.
0001 0010-"16 + 2 = 18-18 bitwise decimal addition 1 Zai plus symbol bit
-"1110 1101-" 1110 1110


Gossip:
017 octal-"decimal
Weight: 1X8 (1) + 7x8 (0) = 15
Multiply the corresponding number by weight, calculate and
Decimal to octal
15-"8 + 7-" 0000 1111-"00 001 111

 

Hexadecimal:
Hexadecimal to decimal
0xff 0 9 A B C D E F
10 11 12 13 14 15 16
15*16 (1) + 15*16 (1) = 255
Convert decimal to hexadecimal
128 = 1000 0000 = 0x80
0 xFFFF FFFF indicates-1 unsigned digit 42 000 000 000
0277777 77777

 

199-"0111 0111 no flights on Wednesday

 

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.