C Language Basics Tutorial (iv) Pointers, structures, unions, and enumerations (18)

Source: Internet
Author: User
Tags definition
Type description
The format of the type description is:
A typedef type definition name;
The type description defines only a new name for a data type rather than a new data type. This type is any one of the data types licensed by Turbo C. The definition name represents the new name for this type.
For example, use the following statement to define the new name for the integer number:
typedef int SIGNED_INT;
After using the instructions, Signed_int becomes synonymous with int, at which point you can define an integer variable with signed_int.
For example: Signed_int I, J; (equivalent to INT I, j).
But Long signed_int I, J; are illegal.
A typedef can also be used to illustrate structures, unions, and enumerations.
Describes the format of a structure as:
typedef struct{
Data type member name;
Data type member name;
...
} structure name;
You can now define the structure variables directly with the structure name. For example:
typedef struct{
Char Name[8];
int class;
Char subclass[6];
Float math, Phys, Chem, Engl, Biol;
} student;
Student Liuqi;
The LIUQI is defined as an array of structures and a structure pointer.
In the file operation described in the second section, files used are an illustrated structure, which is described as follows:
typedef struct
{
Short level;
unsigned flags;
Char FD;
unsigned char hold;
Short bsize;
unsigned char *buffer;
unsigned char *curp;
unsigned istemp;
Short token;
} FILE
This structure description is already included in the stdio.h, as long as the user simply uses the file definition pointer variable. In fact, the purpose of introducing a type description is not for convenience, but for portability of the program.
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.