Thinking in C
Foundations for Java and C++
by Chuck Allison
© 2000 MindView, Inc. http://www.MindView.netNote: Please click here if you haven't performed the installation. Please read the license agreement.
Chapter 1: Introduction and Getting
Started This chapter gives the context for the course (including the level of programming that you should already have) and clarifies course objectives (that is, to find the shortest, most effective path to Java and C++). We take a first look at C programming by examining statements, comments, include files, and standard Input/Output (I/O). Compile and execute two sample programs. (A full description is given at the end of the Chapter 1 lecture.) Here are
the source-code files for the exercises (use these as a starting point for
solving the exercises): Here are
the source-code files for the exercise solutions: |
|
Chapter 2: Fundamental Data
Types Like most languages, C has two flavors of numeric data types: integers and real numbers. Unlike many languages, they come in an array of different sizes. This chapter explores the limits and behavior of C's built-in types and explains converting from one type to another both implicitly and explicitly (i.e., with casting). In this exercise you will learn to round to the nearest integer. (A full description is given at the end of the Chapter 2 lecture.) Here are
the source-code files for the exercises (use these as a starting point for
solving the exercises): Here are
the source-code files for the exercise solutions: |
|
Chapter 3: Operators C has more operators than most languages. Most of these operators are binary operators, some are unary, and there's even a ternary operator (a what? :-). Since C is - among other things -- a systems language, there are operators that access features close to the machine. In this chapter we cover all but five operators (those five are covered in later chapters). You'll also see the way operators work together. In this exercise you'll learn to test the parity (i.e., even-ness/odd-ness) of input numbers. (A full description is given at the end of the Chapter 3 lecture.) Here are
the source-code files for the exercises (use these as a starting point for
solving the exercises): Here are
the source-code files for the exercise solutions: |
|
Chapter 4: Controlling Program
Flow In 1968 a pair of mathematicians proved that all algorithms could be expressed by three simple mechanisms, coupled with an arbitrary number of boolean (logical) flags:
This chapter shows how to use these in C, and then some. In this exercise, you will repeat the exercise from Chapter 3 on an arbitrarily large number of integers. (A full description is given at the end of the Chapter 4 lecture.) Here are
the source-code files for the exercises (use these as a starting point for
solving the exercises): Here are
the source-code files for the exercise solutions: |
|
Chapter 5: Compound Data
Types You can only go so far with numbers. Programming gets interesting when you create complex data types from simpler ones. This chapter discusses arrays (in all dimensions!), illustrates text processing with character strings, and shows you how to create complex data types of your own. In this exercise you will create and process a collection of employee records. (A full description is given at the end of the Chapter 5 lecture.) Here are
the source-code files for the exercises (use these as a starting point for
solving the exercises): Here are
the source-code files for the exercise solutions: |
|
Chapter 6: Programming with
Functions Functions are the building blocks of real-world C programs. Here you'll learn about value semantics, the void type, function prototypes, and the scope (visible region) of identifiers. You'll also come to understand storage class, modularity, and information hiding, which is a key principle of object-oriented programming. In this exercise you will divide the employee program into modules, separating interface from implementation. (A full description is given at the end of the Chapter 6 lecture.) Here are
the source-code files for the exercises (use these as a starting point for
solving the exercises): Here are
the source-code files for the exercise solutions: |
|
Chapter 7: Pointers 101 Pointers are essential for effective systems programming and for implementing complex objects in C++. But if you're going on to Java, you don't need all that machinery. However, you do need some basics because even Java uses pointers (but in a much more restricted way). This chapter gives a minimum coverage of pointers so that you can move on to Java: indirection, reference semantics, and using the heap (dynamic memory). In this exercise, you will modify the employee program to handle dynamic employee records. (A full description is given at the end of the Chapter 7 lecture.) Here are
the source-code files for the exercises (use these as a starting point for
solving the exercises): Here are
the source-code files for the exercise solutions: |
|
Chapter 8a: A first look at
Java You made it! If you're not interested in C++, this is your final stop. Here we look at how Java programs are written and built, and more importantly, how the Java Runtime Environment works. We also look at control flow and how to create objects and arrays. In this exercise you will implement a simple Stack class (first seen in Chapter 7) using Java. (A full description is given at the end of the Chapter 8a lecture.) Here are
the source-code files for the exercises (use these as a starting point for
solving the exercises): Here are
the source-code files for the exercise solutions: |
|
Chapter 8b: Pointers 102 If you're planning to tackle C++, you're not done yet! First you have to become familiar with multiple levels of pointer indirection, pointer arithmetic, making objects read-only via const, generic pointers (void*), and the relationship pointers have with arrays and functions. In this exercise, you will:
(A full description is given at the end of the Chapter 8b lecture.) Here are
the source-code files for the exercises (use these as a starting point for
solving the exercises): Here are
the source-code files for the exercise solutions: |
|
Chapter 9b: A first look at
C++ Relax, it's all downhill from here (until you take your full-blown C++ class :-)! This chapter explains key differences between C and C++, and takes you through three essential C++ features:
Also covered are IOStreams and the free store operators new and delete. In this exercise, you will implement a complete Employee class. (A full description is given at the end of the Chapter 9b lecture.) Here are
the source-code files for the exercises (use these as a starting point for
solving the exercises): Here are
the source-code files for the exercise solutions: |
|
Now that you have enough of an understanding of C, you're ready to move on to your new language of choice: C++ or Java. MindView, Inc. has more resources available for you to learn these languages, including a variety of seminars, training CD Roms like this one, and both of Bruce Eckel's award-winning, freely downloadable books Thinking in C++ and Thinking in Java (available on this CD, see here). Be sure to visit http://www.MindView.net to download your copies of the books, and to learn about the other seminars and CDs! |
|
Source Code You have several options for accessing the source code for all the slides, exercises and solutions. The hyperlinks shown above for all the files in each chapter go to HTML files which can be cut and pasted directly from your browser into your editor or compiling environment. This is a bit tedious, but it works. All the code files are also available in each chapter's subdirectory on this CD ROM. For each chapter, there's a subdirectory called "Code" which contains the source code files. The most convenient form is a ZIP file containing all the source code, which can be copied directly to your hard disk and unzipped; the unzipping process will create all the appropriate files and directories. If you don't have an "unzip" program on your machine, the best place to go for tools is http://www.cdrom.com/pub/infozip/. This is a freeware, open-source implementation of zipping and unzipping programs that work on virtually all platforms. This CD ROM contains a version of INFO-ZIP for 16 & 32 bit DOS and for the Macintosh, in the subdirectory Info-Zip. Here are the readme files for dos and the Macintosh. All questions about INFO-ZIP should be directed to the creators of that program; the INFO-ZIP material is only being included as a convenience and is not an official part of the Thinking in C CD Rom. Info-ZIP's software (Zip, UnZip and related utilities) is free, and can be obtained as source code or executables from Internet/WWW sites, including http://www.cdrom.com/pub/infozip/). Please note: when unzipping (using the above program) for Unix/Linux platforms, remember to use the -a flag, which will correct all the CR/LF issues during the unzipping process. The presentation slides and multimedia on this CD do NOT work on Unix/Linux. Thinking in C++, 2nd edition
book resources This CD Rom also includes electronic versions of the book Thinking in C++, 2nd edition, Volume 1 and source code for the book. Click here to go to the directory containing the versions of the book. Thinking in Java bookThis CD Rom also includes an electronic version of the book Thinking in Java, 2nd edition and source code for the book. Click here to go to the directory containing the versions of the book. Compilers This CD Rom does not include any compilation tools for C, C++ or Java. It is your responsibility to acquire and install the tool of your choice. See here for more details. |
|
Troubleshooting If you have a problem you cannot resolve, please first look at the FAQ. |