iOS Network Programming--day3 (C language Supplement)

Source: Internet
Author: User


1. Constant classification

(1) integer constant only 10 binary with plus or minus integer

%d decimal placeholders print integer constants in 10-based notation

%o Octal placeholders print integer constants in 8-in-one fashion

%x 16 binary placeholder prints integer constants in 16-in-one fashion

10 Binary Integer Write 23

8 binary int write 0 start 023

16 binary integer Write ox opening ox23


Short int 2 bytes 16-bit signed (plus or minus)-32768 ~ 32767

int 4 bytes 32 bits

A long int 8 bytes 64 bits


u unsigned int type

Ul/lu unsigned long integer type


Integers can be divided into positive integers and negative integer storage, positive integers are stored in the original code, negative integers are complement store, the first is the sign bit, 0 is negative, 1 is positive


6 is two bytes, plus or minus can be stored as 1000000000000110,

The way to get the complement: The original code--anti-code (into the opposite number) and complement (+1)

-6 00000000000000110->1111111111111001->111111111111010

(2) Real-type constants

A general form of real numbers: consists of integers, decimal points, and fractions of three parts. An integer part or fractional part can be omitted for example, 12.345, 47.0 、-. 234, 47.

A real number in exponential form: consists of a mantissa, a letter e/e, a decimal point, for example. 2e3, 1.2e-3

(3) Character constants

' 0 ' -48 ' a ' -65 ' a '-97

\ nthe newline-10

\ t Horizontal tab-9

\b Backspace-8

\ r Enter-13

\f Replacement Page-12

\ \ Backslash "\"-92

\ ' single quote-39

\ "Double Quotes-34

\DDD 1 to 3-bit 8 decimal characters represent a maximum of 3-bit octal digits after a slash

\XHH 1 to 2-bit 16 digits represent a character up to a slash x followed by a 2-bit 16 binary number

(4) enumeration constants

General definition integer constant, non-value default starting from 0, add 1, starting from the set value, and then adding 1

Enum weekday{

Monday

Tuesday,

Wednesday = 11,

Thursday,

Friday

Saturday = 33,

Sunday

};


int main (int argc, char * argv[]) {

@autoreleasepool {

Return Uiapplicationmain (argc, argv, Nil, Nsstringfromclass ([Appdelegate class]));

printf ("%d%d%d%d%d%d%d", monday,tuesday,wednesday,thursday,friday,saturday,sunday);

}

}

(5) Macro definitions cannot be added with semicolons

(6) 0 value is the ASCII code value 0 characters

(7) Null numeric 0,\0, pointer null

(8) Const constant

Function: (1) Modify the general variable, you can change the variable into a constant symbol

(2) Modifier pointer variable


2. Pointer, a 16-binary address

Fetch address:&%p: Print at 16-address

Number of addresses removed: *

General form of pointer variables

Type identifier * pointer variable name int a = 100; int *na = &a;

Variable addresses of the same type must be stored using variables of the same type

If initialization is not assigned, it needs to be initialized to null


char * string variable

const char * string constant


3.const modifier pointer

(1) The const int *P can change the address stored in P, but it cannot change the data in the stored address.

(2) Int const *P effect same as (1)

(3) int *const p; The definition must be initialized, the address cannot be changed, but the data stored in the address can be changed

(4) const int *CONST p; You cannot change the address stored in P or change the data in the stored address, and you must initialize it when you define it.


4.static Static variables

(1) Modify the local variables, the first call to open up memory space, after the call does not reclaim memory, retain the previous data, the call will not re-open memory and initialization

(2) Static global variables, global variables can be accessed by external files, static global variables can only be used by this file


5.extern keyword Usage

(1) keywords that declare variables

Conditional precompilation: Only one of these conditions is compiled, and the other does not compile

#if

#else

#endif


iOS Network Programming--day3 (C language Supplement)

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.