section 1.1: Getting Started

page 6

Deep sentence:

With these mechanical details mastered, everything else is comparatively easy.
The claim that a program as simple as ``hello, world'' is a big hurdle may seem outrageous, but it's really quite true. It is a hurdle: on an unfamiliar computer, it can be arbitrarily difficult to figure out how to enter a text file containing program source, or how to compile and link it, or how to invoke it, or what happened after (if?) it ran. The most experienced C programmers immediately go back to this one, simple program whenever they're trying out a new system or a new way of entering or building programs or a new way of printing output from within programs. As they say, everything else is comparatively easy.

One hurdle which the authors don't mention but which many of you may find yourself facing is the choice of an appropriate compiler. On many Unix machines, the cc command which the authors describe is an older compiler which does not recognize modern, ANSI Standard C syntax. An old compiler will accept the simple program on page 6, but it will not accept many of the other programs in the book. If you find yourself getting baffling compilation errors on programs which you've typed in exactly as they're shown in the book, it probably indicates that you're using an older compiler. On many machines, another compiler called acc or gcc is available, and you'll want to use it, instead.

Deep sentence:

main will usually call other functions to help perform its job, some that you wrote, and others from libraries that are provided for you.
We heard about this already in the Introduction, but here it is again: as far as the compiler and the language definition are concerned, there's no difference between a function that you write and a function someone else wrote for you, including a function like printf which seems to be part of the language. There's nothing magic about printf; there's nothing that it can do that one of your functions couldn't. (Well, actually, there are a few magic, or at least surprising, things about printf, but they're magic in ways that your functions can be, too.)

There is one slight problem with the simple ``hello, world'' program in the book. The problem will usually be ignored (that is, the program will usually work correctly), but if you receive any warning or error messages or have any problems having to do with the ``value returned from main,'' jump forward to page 26 to learn why main ought to end with the line

	return 0;


Read sequentially: prev next up top

This page by Steve Summit // Copyright 1995, 1996 // mail feedback