* X more docs for C
[mascara-docs.git] / C / the.ansi.c.programming.language / c.programming.notes.int / sx1.html
blob3f07c7145794fe0a5d6f5600d8572b96a00dab7f
1 <!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
2 <!-- This collection of hypertext pages is Copyright 1995-7 by Steve Summit. -->
3 <!-- This material may be freely redistributed and used -->
4 <!-- but may not be republished or sold without permission. -->
5 <html>
6 <head>
7 <link rev="owner" href="mailto:scs@eskimo.com">
8 <link rev="made" href="mailto:scs@eskimo.com">
9 <title>Chapter 15: User-Defined Data Structures</title>
10 <link href="top.html" rev=precedes>
11 <link href="sx1a.html" rel=precedes>
12 <link href="top.html" rev=subdocument>
13 </head>
14 <body>
15 <H1>Chapter 15: User-Defined Data Structures</H1>
17 <p>So far, we have been using C's basic types--<TT>char</TT>,
18 <TT>int</TT>, <TT>long int</TT>, <TT>double</TT>,
19 etc.--and a few <dfn>derived</dfn>
20 types--arrays of basic types,
21 pointers to basic types,
22 and functions returning basic types.
23 In this chapter, we'll learn about another way to derive types:
24 by building user-defined types.
25 </p><p>There's an old joke about
26 Henry Ford saying that
27 you could get the Model T in any color you wanted,
28 as long as it was black.
29 User-defined data types have a little bit of the same restriction:
30 you don't have ultimate flexibility;
31 you can define your own data types any way you want,
32 as long as they're collections of other types.
33 (What you couldn't define would be data types that held, say,
34 tractors or teddy bears or Model T Fords,
35 because of course computers have no way of holding those objects.
36 You're ultimately restricted to the primitive types of data
37 which computers can represent,
38 and C's basic types cover most of those.)
39 </p><p>Very roughly speaking,
40 a structure is a little bit like an array.
41 An array is a collection of associated values, all of the same type.
42 A structure is a collection of associated values,
43 but the values can all have different types.
44 </p><p><a href="sx1a.html" rel=subdocument>15.1: Structures</a></p>
45 <p><a href="sx1b.html" rel=subdocument>15.2: Accessing Members of Structures</a></p>
46 <p><a href="sx1c.html" rel=subdocument>15.3: Operations on Structures</a></p>
47 <p><a href="sx1d.html" rel=subdocument>15.4: Pointers to Structures</a></p>
48 <p><a href="sx1e.html" rel=subdocument>15.5: Linked Data Structures</a></p>
49 <hr>
50 <p>
51 Read sequentially:
52 <a href="top.html" rev=precedes>prev</a>
53 <a href="sx1a.html" rel=precedes>next</a>
54 <a href="top.html" rev=subdocument>up</a>
55 <a href="top.html">top</a>
56 </p>
57 <p>
58 This page by <a href="http://www.eskimo.com/~scs/">Steve Summit</a>
59 // <a href="copyright.html">Copyright</a> 1996-1999
60 // <a href="mailto:scs@eskimo.com">mail feedback</a>
61 </p>
62 </body>
63 </html>