tailieunhanh - the ansi c programming phần 6

Cho đến 1973, C đã trở nên đủ mạnh để dùng viết nhân cho Unix, thay vì trước nó chúng được viết bằng Assembly trong các máy PDP-11/20. Đây là lần đầu tiên mà nhân của một hệ điều hành được lắp thành bằng một ngôn ngữ khác hơn Assembly. | 106 struct . x y z is syntactically analogous to int x y z in the sense that each statement declares x y and z to be variables of the named type and causes space to be set aside for them. A structure declaration that is not followed by a list of variables reserves no storage it merely describes a template or shape of a structure. If the declaration is tagged however the tag can be used later in definitions of instances of the structure. For example given the declaration of point above struct point pt defines a variable pt which is a structure of type struct point. A structure can be initialized by following its definition with a list of initializers each a constant expression for the members struct maxpt 320 200 An automatic structure may also be initialized by assignment or by calling a function that returns a structure of the right type. A member of a particular structure is referred to in an expression by a construction of the form The structure member operator ÁÁ. connects the structure name and the member name. To print the coordinates of the point pt for instance printf d d or to compute the distance from the origin 0 0 to pt double dist sqrt double dist sqrt double double Structures can be nested. One representation of a rectangle is a pair of points that denote the diagonally opposite corners struct rect struct point pt1 struct point pt2 The rect structure contains two point structures. If we declare screen as struct rect screen then 107 refers to the x coordinate of the pti member of screen. Structures and Functions The only legal operations on a structure are copying it or assigning to it as a unit taking its address with and accessing its members. Copy and assignment include passing arguments to functions and returning values from functions as well. Structures may not be compared. A structure may be initialized by a list of constant member values an automatic structure may also be .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.