Learn C language--the first day

Source: Internet
Author: User

Today began to decide, began to learn C language, the Internet is flooded with a variety of introductory books, a variety of fast learning C language programming information. But I'm a person in contact with the surrounding yards for more than 4 years, I know clearly, the fastest way to learn is to start by looking at the code.

But the most basic is to be familiar with, university period, learned some C has also learned a few C + +, but that is only to earn credit, nothing learned.

The advantages of the C language:

Both high-level language and low-level language advantages, belong to an intermediate language.

is a structured programming language that is well suited for structured programming.

There are a wealth of data types, operators, and functions to choose from.

Dealing directly with memory makes it easy and easy to modify and edit other programs and documents.

The gate of learning C is an algorithm and data structure, the pointer is an important part of data structure, most of the data structures are built on pointers, such as linked lists, queues, trees, graphs and so on.

Let's start with Xinxin Sun's teacher today.

The first chapter is how the Windows program works inside. Understand that the application to complete a function is implemented as a function call. The application also notifies the operating system to perform the corresponding function in the form of a function call.

The operating system provides the functionality it can perform as a function to the application, collectively known as the Windows API (Application programming Interface).

If CreateWindow is an API function, the application calls this function and the operating system generates a corresponding window according to the parameter information provided by the function.

message and Message Queuing, the operating system implements a message mechanism to pass a perceived event to an application. Each event is packaged into a struct called a message.

typedef struct tagmsg{

HWND hwnd;

UNIT message;

WPARAM WPARAM;

LPARAM Iparam;

DWORD time;

Point pt;

}msg;

Handle (HANDLE), the identity of the resource. The operating system to manage and manipulate these resources is through a handle to find the corresponding resource, by the type of the resource can be subdivided into the handle of the icon handle (HICON), the cursor handle (hcursor), the window handle (HWND), the application instance handle (HINSTANCE).

Entry functions for Windows programs

int WINAPI WinMain (

HINSTANCE HInstance,

HInstance hPrevInstance,

Instance

LPSTR lpCmdLine,

int nCmdShow

);

Creating a complete window takes you through: Designing a window class, registering the window class, creating Windows, displaying and updating Windows.

Design window class:

typedef struct_wndclass{

UNIT style;//The type of the window class, and each bit (bit) of each class variable corresponds to an attribute.

WNDPROC Lpfnwndproc; A window procedure function, also called a callback function. The code for the callback function must be done by the application itself. A function specified by the LPFNWNDPROC member of the application to which a message operating system is called.

int Cbclsextra;

int Cbwndextra;

HANDLE hinstance;

Hicon Hicon;

Hcursor Hcursor;

Hbrush Hbrbackground;

LPCTSTR Lpszmenuname;

LPCTSTR lpszClassName;

}wndclass;

Variable: A variable is a space for storing the value of the data. Because there are many types of numeric values, such as integers, decimals, and so on, the corresponding variables have integer variables, floating-point variables, character-type variables, and so on.

Naming rules for identifiers:

Identifiers can only have letters, numbers and underscores of three types of characters;

The first character must be a letter;

Uppercase and lowercase letters are considered to be two different characters.

Identifiers can be arbitrarily long, but only the first 32 bits are valid.

The identifier cannot be a keyword of c.

Learn C-First day

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.