First to fourth useUse one:Defines an alias for a type, not just a simple macro substitution. Can be used as multiple objects that declare a pointer type at the same time. For example: char* PA, PB; The majority does not conform to our intention, it only declares a pointer to a character variable,//and a character variable; The following is possible: typedef char* PCHAR; General use capital PCHAR PA, PB; Possible, while declaring two pointers to chara
only declares a pointer to a character variable,
// And a character variable;
The following are feasible:
Typedef char * PCHAR; // generally, uppercase is used.
PCHAR pa, pb; // feasible. Two pointers pointing to character variables are declared at the same time.
Although:
Char * pa, * pb;
It is also feasible, but it is not intuitive in the form of typedef, especially where a large number of pointers are r
I. Introduction to the Role of typedef1 /*2 1. Function: A new name for the existing type3 4 2. Use the occasion:5 1> Basic data Types6 2> Pointer7 3> Structural Body8 4> Enumeration9 5> pointers to functionsTen */ One A#include - -typedefintMyInt; the typedef MyInt MYINT2; - - //give pointer type char * A new type name string -typedefChar*String; + - /* + struct Student A { at int age; - }; -
Original address: http://www.cnblogs.com/charley_yang/archive/2010/12/15/1907384.htmlFirst to fourth useUse one:Defines an alias for a type, not just a simple macro substitution. Can be used as multiple objects that declare a pointer type at the same time. Like what:char* PA, PB; The majority does not conform to our intent, it only declares a pointer to a character variable,and a character variable;The following are possible:typedef char* PCHAR; General capitalizationPCHAR PA, PB; It is possible
typedef appear together, the typedef will not be a simple string substitution.Trap Two:A typedef is syntactically a keyword that stores a class (such as auto, extern, mutable, static, register, and so on), although it does not really affect the storage characteristics of an object, such as:typedef static INT INT2; Not feasibleThe compilation will fail with the h
then use an alias in the main function to define the variable, which is exactly the same as the original primitive type. Output Result:Of course, the original int, float can still be used normally after giving the type an alias:int i = 10;float f = 10.0f;* You can also alias an alias based on thetypedef int INTEGER;TYPEDEF Integer Myinteger;Back to top two, typedef and pointersA
1. typedef int (init_fnc_t) (void); it indicates that init_fnc_t is defined as the function type. This function returns int type and has no parameter. "init_fnc_t * init_sequence [] = {cpu_init, board_init}" indicates that a one-dimensional pointer array is defined using init_fnc_t (function type). All elements in the array are pointer variables, they all point to function pointers. The return values of these functions are int type and have no parame
[Learning notes] [C Language] typedef, learning notes typedef
1. Concept
We can use the typedef keyword to define a new name (alias) for various data types ).
2. Role: Create a new name for an existing type
3. Application scenarios:1> Basic Data Type2> pointer3> struct4> Enumeration5> pointer to function
4. Code
1 # include
Usage notes
1 # include
Purpose 1: Define a type of Alias, not just a simple macro replacement. It can be used as multiple objects that declare the pointer type at the same time. For example: char * pa, pb; // most of them do not conform to our intention. It only declares a pointer to a character variable, // and a character variable. The following is feasible: typedef char * PCHAR; // generally, uppercase PCHAR pa and pb are used. // It is feasible to declare two pointers p
I. Introduction to the Role of typedef* We can use the TypeDef keyword to define a new name (alias) for various data types.#include typedefintinteger;typedef unsignedintUinterger;typedeffloatFloat;intMainintargcConst Char*argv[]) {Integer I= -Ten; Uinterger UI= One; Float F=12.39f; printf ("%d%d%.2f", I, UI, F); return 0;}The 3rd, 4th, and 6th lines give an alias
First to fourth useUse one:Defines an alias for a type, not just a simple macro substitution. Can be used as multiple objects that declare a pointer type at the same time. Like what:char* PA, PB; The majority does not conform to our intent, it only declares a pointer to a character variable,and a character variable;The following are possible:typedef char* PCHAR; General capitalizationPCHAR PA, PB; It is possible to declare two pointers to a character variableAlthough:Char *pa, *PB;Also feasible,
Http://www.cnblogs.com/charley_yang/archive/2010/12/15/1907384.htmlFirst to fourth useUse one:Defines an alias for a type, not just a simple macro substitution. Can be used as multiple objects that declare a pointer type at the same time. Like what:char* PA, PB; The majority does not conform to our intent, it only declares a pointer to a character variable,and a character variable;The following are possible:typedef char* PCHAR; General capitalizationPCHAR PA, PB; It is possible to declare two po
1. Basic explanationTypedef is a key word in C language. It defines a new name for a data type. The data types here include internal data types (INT, Char, etc.) and Custom Data Types (struct, etc ).In programming, typedef is generally used for two purposes. One is to give a variable a new name that is easy to remember and clear, and the other is to simplify some complicated type declarations.As for the sub
In C + + code, the typedef uses a lot, especially in C code. typedef and #define Some similar, in fact, is different, especially in some complex usage, read some of the online C/s + + Learner's blog, which has a summary of the typedef is very good, because the summary is very good, I will not modify the quote came over, Add an analysis of your own.
Basic Defini
I. Introduction to the role of TypeDef* We can use the TypeDef keyword to define a new name (alias) for various data types.1 #include 8 int main (int argc, const char * argv[]) {9 Integer i = -10;10 Uinterger ui = 11;11 , Float f = 12. 39f;13 printf ("%d %d %.2f", I, UI, f); return 0;17}The 3rd, 4th, and 6th lines give an alias to int, unsigned int, float, and then use an alias in
that does not support long double, change:
Typedef double REAL;
On Platform 3 that is not supported by double, change:
Typedef float REAL;
That is to say, when using a cross-platform system, you only need to change the typedef itself, without any modifications to other source codes.
This technique is widely used in the standard library, such as size_t.
TypeDef is more convenient.
Use two:Used in the old C code (the specific old did not check), to help struct. In previous code, when declaring struct a new object, you must take a struct, in the form of a struct struct name obje
I. struct sockaddr_in, struct sockaddr, struct in_addr
Struct sockaddr_in, struct sockaddr, struct in_addr, which is a common struct in network programming. Each time they cannot rememb
,[r1, #2][0XE1A02C20] mov r2,r0,lsr #24[0xe5c12003] Strb r2,[r1, #3][0xe1a0f00e] mov pc,r14*//*If Q does not have a __packed modifier then the assembler command is such that direct access to the singular address fails[0xe59f2018] Ldr r2,0x20001594; = #0x87654321[0xe5812000] str r2,[r1, #0]*/This makes it clear how non-aligned access produces errors.And how to eliminate non-aligned access poses problemsYou can also see non-aligned Access and aligned access instruction differences leading to effic
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.