Chapter 3. Compiling and Running Your First Program

IN THIS CHAPTER, YOU ARE INTRODUCED to the C language so that you can see what programming in C is all about. What better way to gain an appreciation for this language than by taking a look at an actual program written in C?

To begin with, you’ll choose a rather simple example—a program that displays the phrase “Programming is fun.” in your window. Program 3.1 shows a C program to accomplish this task.

Example 3.1. Writing Your First C Program

#include <stdio.h>

int main (void)
{
     printf ("Programming is fun.\n");

     return 0;
}

In the C programming language, lowercase and uppercase letters are distinct. In addition, in C, it does not matter where on the line you begin typing—you can begin typing your ...

Get Programming in C, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.