In just 21 days, you'll have all the skills you need to get started with C. With this complete tutorial, you'll master the basics and them move on to the more advanced features and concepts. Understand the fundamentals of C. Master all the new and advanced features that C offers. Learn how to effectively use the latest tools and features of C, by following practical, real-world examples. Includes a CD with all code examples and an ANSI-compliant C compiler. IMPORTANT NOTE: Windows XP or 32-bit Windows 7 recommended — will not run on 64-bit Windows systems!
Author(s): Bradley Jones, Peter Aitken
Edition: 6th Edition
Publisher: Sams Publishing
Year: 2002
Language: English
Pages: 957
Tags: Библиотека;Компьютерная литература;C / C++;
Sams Teach Yourself C in 21Days, Sixth Edition......Page 2
Copyright © 2003 by Sams Publishing......Page 3
Contents at a Glance......Page 4
Table of Contents......Page 6
About the Authors......Page 25
We Want to Hear from You!......Page 27
This Book’s Special Features......Page 28
Making a Better Book......Page 30
Conventions Used in This Book......Page 31
Where You’re Going......Page 32
A Brief History of the C Language......Page 34
Why Use C?......Page 35
Preparing to Program......Page 36
The Program Development Cycle......Page 37
Your First C Program......Page 43
Q&A......Page 47
Workshop......Page 48
TYPE & RUN 1 Printing Your Listings......Page 52
The First Type & Run......Page 53
A Short C Program......Page 56
The Program’s Components......Page 58
A Review of the Parts of a Program......Page 63
Q&A......Page 65
Workshop......Page 66
DAY 3 Storing Information: Variables and Constants......Page 68
Understanding Your Computer’s Memory......Page 69
Storing Information with Variables......Page 70
Numeric Variable Types......Page 71
Constants......Page 77
Q&A......Page 83
Workshop......Page 84
DAY 4 The Pieces of a C Program: Statements, Expressions, and Operators......Page 86
Statements......Page 87
Understanding Expressions......Page 89
Operators......Page 91
The if Statement......Page 100
Evaluating Relational Expressions......Page 105
The Logical Operators......Page 108
More on True/False Values......Page 110
Operator Precedence Revisited......Page 114
Summary......Page 115
Workshop......Page 116
TYPE & RUN 2 Find the Number......Page 120
DAY 5 Packaging Code in Functions......Page 124
What Is a Function?......Page 125
How a Function Works......Page 127
Functions and Structured Programming......Page 129
Writing a Function......Page 132
Passing Arguments to a Function......Page 141
Calling Functions......Page 142
Where the Functions Belong......Page 145
Summary......Page 146
Q&A......Page 147
Workshop......Page 148
DAY 6 Basic Program Control......Page 150
Arrays: The Basics......Page 151
Controlling Program Execution......Page 152
Nested Loops......Page 169
Summary......Page 170
Workshop......Page 171
DAY 7 Fundamentals of Reading and Writing Information......Page 174
Displaying Information On-Screen......Page 175
Inputting Numeric Data with scanf()......Page 184
Using Trigraph Sequences......Page 189
Summary......Page 190
Workshop......Page 191
WEEK 1 In Review......Page 194
Where You’re Going......Page 200
What Is an Array?......Page 202
Naming and Declaring Arrays......Page 208
Q&A......Page 218
Workshop......Page 219
DAY 9 Understanding Pointers......Page 222
What Is a Pointer?......Page 223
Pointers and Simple Variables......Page 224
Pointers and Variable Types......Page 228
Pointers and Arrays......Page 229
Pointer Cautions......Page 237
Passing Arrays to Functions......Page 238
Summary......Page 243
Workshop......Page 244
TYPE & RUN 3 Pausing for a Second or Two......Page 246
DAY 10 Working with Characters and Strings......Page 250
Using Character Variables......Page 251
Using Strings......Page 254
Strings Without Arrays......Page 256
Displaying Strings and Characters......Page 262
Reading Strings from the Keyboard......Page 264
Summary......Page 270
Q&A......Page 271
Workshop......Page 272
DAY 11 Implementing Structures, Unions, and TypeDefs......Page 276
Working with Simple Structures......Page 277
Using Structures That Are More Complex......Page 281
Arrays of Structures......Page 287
Initializing Structures......Page 290
Structures and Pointers......Page 293
Understanding Unions......Page 302
Creating Synonyms for Structures with typedef......Page 308
Q&A......Page 309
Workshop......Page 310
DAY 12 Understanding Variable Scope......Page 312
What Is Scope?......Page 313
Creating External Variables......Page 315
Creating Local Variables......Page 318
Which Storage Class Should You Use?......Page 323
Local Variables and Blocks......Page 324
Q&A......Page 326
Workshop......Page 327
TYPE & RUN 4 Secret Messages......Page 332
DAY 13 Advanced Program Control......Page 336
Ending Loops Early......Page 337
The goto Statement......Page 341
Infinite Loops......Page 343
The switch Statement......Page 348
Exiting the Program......Page 356
Executing Operating System Commands in a Program......Page 357
Q&A......Page 360
Workshop......Page 361
Streams and C......Page 364
Using C’s Stream Functions......Page 367
Accepting Keyboard Input......Page 369
Controlling Output to the Screen......Page 385
Redirecting Input and Output......Page 395
When to Use fprintf()......Page 397
Summary......Page 399
Q&A......Page 400
Workshop......Page 401
WEEK 2 In Review......Page 404
Where You’re Going......Page 412
Declaring Pointers to Pointers......Page 414
Pointers and Multidimensional Arrays......Page 416
Working with Arrays of Pointers......Page 424
Working with Pointers to Functions......Page 433
Bonus Section: Understanding Linked Lists......Page 443
Q&A......Page 461
Workshop......Page 462
Relating Streams to Disk Files......Page 466
Using Filenames......Page 467
Opening a File......Page 468
Writing and Reading File Data......Page 472
File Buffering: Closing and Flushing Files......Page 482
Understanding Sequential Versus Random File Access......Page 484
Detecting the End of a File......Page 490
File Management Functions......Page 492
Using Temporary Files......Page 497
Summary......Page 498
Q&A......Page 499
Workshop......Page 500
TYPE & RUN 5 Counting Characters......Page 502
Determining String Length......Page 508
Copying Strings......Page 510
Concatenating Strings......Page 514
Comparing Strings......Page 517
Searching Strings......Page 521
String Conversions......Page 528
Miscellaneous String Functions......Page 529
String-to-Number Conversions......Page 531
Character Test Functions......Page 533
Workshop......Page 539
Passing Pointers to Functions......Page 542
Type void Pointers......Page 547
Using Functions That Have a Variable Number of Arguments......Page 550
Functions That Return a Pointer......Page 553
Summary......Page 555
Workshop......Page 556
Mathematical Functions......Page 560
Dealing with Time......Page 564
Error-Handling......Page 570
Searching and Sorting......Page 575
Summary......Page 583
Workshop......Page 584
TYPE & RUN 6 Calculating Mortgage Payments......Page 588
Type Conversions......Page 592
Allocating Memory Storage Space......Page 597
Manipulating Memory Blocks......Page 606
Working with Bits......Page 609
Q&A......Page 615
Workshop......Page 616
Programming with Multiple Source- Code Files......Page 620
The C Preprocessor......Page 628
Predefined Macros......Page 638
Using Command-Line Arguments......Page 639
Summary......Page 641
Workshop......Page 642
WEEK 3 In Review......Page 646
Where You’re Going......Page 654
BONUS DAY1 Object-Oriented Programming Languages......Page 656
Procedural and Object-Oriented Languages......Page 657
The Object-Oriented Constructs......Page 658
The Java Programming Language......Page 668
The C# Programming Language......Page 672
Workshop......Page 673
BONUS DAY2 The C++ Programming Language......Page 676
Hello C++ World!......Page 677
Understanding the C++ Keywords......Page 679
Declaring Variables in C++......Page 680
Working with Functions in C++......Page 682
Summary......Page 688
Workshop......Page 689
BONUS DAY3 Working with C++ Classes and Objects......Page 692
Working with Complex Data in C++......Page 693
Using Classes......Page 701
Creating Access Member Functions......Page 707
Structures Versus Classes......Page 710
Starting with Constructors......Page 711
Function Overloading Revisited......Page 713
Review of the OOP Constructs in C++......Page 714
Using Classes as Data Members......Page 715
Inheriting in C++......Page 716
A Caution on What You’ve Learned About C++......Page 725
Q&A......Page 726
Workshop......Page 727
Structure of a Java Program......Page 730
Java Program Essentials......Page 731
Java Keywords......Page 733
Java Identifiers......Page 734
Data Types......Page 735
Input and Output......Page 740
Arrays......Page 742
Operators......Page 743
Flow Control......Page 744
Workshop......Page 747
Defining a Class......Page 750
Class Methods......Page 754
Using Inheritance......Page 763
Q&A......Page 767
Workshop......Page 768
Working with Java Exceptions......Page 770
Reading and Writing Files......Page 772
Doing Graphics and Windows......Page 776
Programming Java Applets......Page 785
Q&A......Page 790
Workshop......Page 791
What Is C#?......Page 792
Why C#?......Page 793
C# Versus Other Programming Languages......Page 796
Creating a C# Program......Page 797
Your First C# Program......Page 800
Displaying Basic Information......Page 801
C# and the Web......Page 803
Q&A......Page 805
Workshop......Page 806
WEEK 4 Bonus Week in Review......Page 808
APPENDIX A ASCII Character Chart......Page 810
APPENDIX B C/C++ Reserved Words......Page 816
The Decimal Number System......Page 820
The Hexadecimal System......Page 821
APPENDIX D Portability Issues......Page 824
Guaranteeing ANSI Compatibility......Page 827
Using Portable Numeric Variables......Page 828
Portable Structures and Unions......Page 842
Q&A......Page 847
Workshop......Page 848
APPENDIX E Common C Functions......Page 850
Answers for Day 1......Page 856
Answers for Day 2......Page 858
Answers for Day 3......Page 859
Answers for Day 4......Page 861
Answers for Day 5......Page 863
Answers for Day 6......Page 867
Answers for Day 7......Page 869
Answers for Day 8......Page 874
Answers for Day 9......Page 878
Answers for Day 10......Page 880
Answers for Day 11......Page 884
Answers for Day 12......Page 885
Answers for Day 13......Page 890
Answers for Day 14......Page 891
Answers for Day 15......Page 893
Answers for Day 16......Page 894
Answers for Day 17......Page 895
Answers for Day 18......Page 896
Answers for Day 19......Page 898
Answers for Day 20......Page 899
Answers for Bonus Day 1......Page 901
Answers for Bonus Day 2......Page 902
Answers for Bonus Day 3......Page 903
Answers for Bonus Day 5......Page 904
Answers for Bonus Day 7......Page 905
APPENDIX G Getting Started with Dev-C++......Page 908
Installing Dev-C++ on Microsoft Windows......Page 909
Using Dev-C++......Page 912
Summary......Page 919
INDEX......Page 920