C Foundation--Constant variable note

Source: Internet
Author: User

Program Compile link principle
Preprocessing:. C. i
GCC-E Hello.c-o hello.i

Compiling:. I/. C. S
Gcc-s Hello.i-o Hello.s

Compilation:. S. o
Gcc-c Hello.s-o hello.o

Link:. O-Executable app
GCC Hello.o-o App

Gedit hello.c

Small-end storage Method-high address memory high byte, low address low memory byte (survivable high, low save low)
(Intel/arm)
0x indicates hexadecimal

Value: 0x12 34 56 78 How to store in small-end memory

0x80030x12
0x80020x34
0x80010x56
0x8000 0x78

1 BYTE = 8bit

Big-endian storage Method--high address memory low byte, low address memory high byte (survivable low, low storage height)
(IBM mainframe/network byte order)
Value: 0x12 34 56 78 How to store in small-end memory

0x80030x78
0x80020x56
0x80010x34
0x8000 0x12

Binary conversion
10 Binary: 0,1,2,3,4,5,6,7,8,9,10
2 binary: 0,1
8 binary: 0,1,2,3,4,5,6,7
16 Binary: 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f

Bashing
1 2 3

1x10^2 + 2x10^1 + 3x10^0

0 1 0
0x2^2 + 1x2^1 + 0x2^0 = 2

1100 1010
0+2+0+8+64+128=202

Binary: 000 001 010 011 100 101 110 111 001000
Decimal: 01 2 3 4 5 6 7 8
Octal: 01 2 3 4 5 6 7 10


binary: 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Decimal: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F


Binary: 1010 0001 1000
Hex: A 1 8

Hex: 3d7
Binary: 0011 1101 0111

Octal: 11
Binary: 001 001

37
Octal Start: 0
Hex Start: 0x
Decimal start: Nothing to do with


Octal: 0777
Hex: 0xffff8000

5 binary: 3x5^0 + 2x5^1 = 13

8 4 2 1

2^3 2^2 2^1 2^0


1000 0100 0010 0001

0111

Decimal: 89 corresponds to binary 1011001
89 ..... 1
44 ..... 0
22 ..... 0
11 ..... 1
5 ..... 1
2 ..... 0
1 ..... 1


1011001
1+0+0+8+16+0+64 = 89

49 ... 1
24 ... 0
12 ... 0
6 ... 0
3 ... 1
1 ... 1

0011 0001
0x31


0567
101 110 111

Bit bits

8bit = 1BYTE = "Each byte has an address

0x8003
0x8002
0x8001
0x8000


1 and-1

Original code anti-code complement

10000 00010000 00010000 0001 positive Inverse code, complement is equal to the original code
-11000 00011111 11101111 1111 The complement of negative numbers equals the inverse code plus 1.

00000 00000000 00000000 0000
-01000 00001111 11110000 0000

if (0 equals-0)
Execute AAAA;
Otherwise
implementation of BBBB;

97 = "97 ... 1 = 0110 0001
48 ... 0
24 ... 0
12 ..... 0
6 ... 0
3 ... 1
1 ... 1
Original code anti-code complement
-31 = = 31 ... 1 = 0001 1111 = 1001 1111 = 1110 0000 = 1110 0001
15 ... 1
7 ... 1
3 ... 1
1 ... 1


char B = 1; = ( -128~127)
unsigned char a = 129; = (0~255)
S
0000 0000
1000 0001
1111 1111
Int
unsigned int (0~2^32-1)


Char b = ' x ';
int c = 10;

' x ' = 0111 1000
Ten-1010
.
.
.
0x8003
0x8002
0x8001
&b = 0x8000 1BYTE 0111 1000
.
.
.
0x70030000 0000=>0x00
0x70020000 0000=>0x00
0x70010000 0000=>0x00
&c =>0x7000 0000 1010=>0x0a
printf ("&c =%p\tc =%d", &c, C);

' X ' = 120
' \a '
‘"‘
345

"Hello" = "h" E "L" ' O "


' a ' = = ' a '
"A" = "C";

"123" = 123

' 1 ' 2 ' 3 '

' 1 '-' 0 ' = 1
1*10 + ' 2 '-' 0 ' = 12
12*10 + ' 3 '-' 0 ' = 123


int a = 5;
A% 3 = 2
A/2 = 2

Float A = 5.0
A% 3 =??? Error
A/2 = 2.5

1. Print basic data type sizeof size
2. Use vs2013 to see the memory and see the values in the address and address of the variable.

C Foundation--Constant variable note

Related Article

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.