Sams Teach Yourself C in 21 Days

(singke) #1
Getting Started with C 21

1


Q If my compiler came with an editor, do I have to use it?
ADefinitely not. You can use any editor, as long as it saves the source code in text
format. If the compiler came with an editor, you should try to use it. If you like a
different editor better, use it. I use an editor that I purchased separately, even
though all my compilers have their own editors. The editors that come with com-
pilers are getting better. Some of them automatically format your C code. Others
color-code different parts of your source file to make it easier to find errors.
Q What do I do if I only have a C++ compiler and not a C compiler?
AAs mentioned in today’s lesson, C++ is a superset of C. This means that you can
use a C++ compiler to compile C programs. Most people use Microsoft’s Visual
C++ to compile their C programs on Windows and GNU’s compiler on Linux and
UNIX. The compilers included with this book’s CD will compile both C and C++
programs.
Q Can I ignore warning messages?
ASome warning messages don’t affect how the program runs, and some do. If the
compiler gives you a warning message, it’s a signal that something isn’t right.
Most compilers let you set the warning level. By setting the warning level, you can
get only the most serious warnings, or you can get all the warnings, including the
most minute. Some compilers even offer various levels in-between. In your pro-
grams, you should look at each warning and make a determination. It’s always best
to try to write all your programs with absolutely no warnings or errors. (With an
error, your compiler won’t create the executable file.)

Workshop ..............................................................................................................

The Workshop provides quiz questions to help you solidify your understanding of the
material covered and exercises to provide you with experience in using what you’ve
learned. Try to understand the quiz and exercise answers before continuing to tomorrow’s
lesson. Answers are provided in Appendix F, “Answers.”

Quiz ................................................................................................................


  1. Give three reasons why C is the best choice of a programming language.

  2. What does the compiler do?

  3. What are the steps in the Program Development Cycle?

  4. What command do you need to enter in order to compile a program called pro-
    gram1.c with your compiler?


03 448201x-CH01 8/13/02 11:14 AM Page 21

Free download pdf