C Language Knowledge Summary

Source: Internet
Author: User

Understand some variables

Be familiar with some statements

Combine some functions

C--"library to help you write it in the library.

The number of magic numbers out of thin air, do not know the meaning of the digital representation, affecting the readability of the code.

C Voice parameter transfer is very special, passing is an alias.

---------------------------------------------

The main function is the entrance to the C program.

#include <stdlib.h>

System ("pause"); Time out

System ("CLS");//Clear screen

printf output System Library functions

A variable is a name that represents a memory address (the size of the memory) that can be changed within the program.

The median value of a variable is the data stored in memory.

The data type of the variable represents the memory size that this variable occupies.

Basic data types for C languages

Short: Shorter, 16bit (two bytes, one byte =8bit)

Unsigned: 0~2^16-1 represents a positive number

Signed: -2^8~2^8-1 indicates positive negative numbers

int: Plastic, 32bit

Unsigned: 0~2^32-1

Signed: -2^16-1~2^16-1

FLOAT: single-precision float, 32bit

Double: dual-precision floating-point, 64bit

Long: Plastic, 32bit

Char: Character type, 8bit

BOOL: Boolean type, 0 and 1,8bit True (True)/false (false)

void: null type, when function declaration does not return a value, use void

sizeof: Calculates the size of a variable or data type that occupies memory.

The undsigned keyword is preceded by the data type, and the variable is the unsigned type data.

inum+=2 and inum=inum+2 mean the same thing.

inum-=2 and inum=inum=2 mean the same thing.

inum3=inum++ for post + +, the value of the variable is first paid to the left variable, and then a +1 operation

Inum2=++inum represents the first + +, the variable is first a +1 operation, the value after +1 is paid to the left of the variable

inum3=inum--after--------first, the value of the variable is paid to the left variable, and then a-1 operation

Inum2=--inum represents the front-----the variable is first 1, then the value after 1 is paid to the left variable.

scanf: Getting basic data type data

Gets: Gets a string

————————————————

if (conditional expression)

{

Statement block

}

else if (conditional expression)

{

Statement block

}

Else

{

Statement block

}

————————————————

Switch (digital)

{

Case Number:

Break

  

Case Number:

Break

Default

Break

}

————————————————

for (expression 1; expression 2; expression 3)

{

}

————————————————

Wihile (conditional expression)

{

Loop body

}

————————————————

Do

{

Loop body

}while (conditional expression)

————————————————

Break Exit Loop

Continue jump to loop start, re-execute

\ s Indicates the end of the string, which is an invisible character

Char array[]= "Hello"; Does not specify an array size, this must be initialized

Char array[10]={0}; There is no definite value, the initialization of all zeros is initialized only at the time of definition.

**************************************************

Atoi string converted to shaped number

Atof string conversion to single-precision floating-point

Atol string to long shaped number

The pointer before using to determine whether the pointer variable is empty, ran out if not empty, but also to release.

The pointer is the address of the variable.

Pointers are also types, and the type of the pointer indicates the address of the data type to which the pointer is pointing.

int * pa=null;//defines a shaping pointer that can hold the address of a shaped scalar

int a=10;

pa=&a;//& Fetch Address character

int b=*pa;//Gets the value in the address saved by the PA

int isize=10;

int * pint= (int *) malloc (sizeof (init) *isize);//equivalent to 10 elements of a shaped array

Free (PInt);//Release memory

***********************************************

There are two types of parameters that are passed in the C language:

1) Value passing: It is a value passed to the function

2) pointer passing: Within the function can change the value of the address of the pointer, this value call after the end of this change has been valid.

int & AA is a reference in C + +

******************************

Security storage media: Disk files, tape files

By file encoding (stored form): Text file, binary file

File operation:

Open file-"file read and write-" Close file

Open file: Establish the user program and file contact, to allocate a file buffer for the file.

Read and write files: refers to the reading, writing, appending, and locating operations

Close file: Disconnect the file from the program and release the file buffer.

C Language Knowledge Summary

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.