Friday, February 11, 2011

Practice! A helpful rules program

To help you under­ stand the most easily offended C rules, I have summarized them in the follow­ing program. It displays several lines of text that remind you of the basic rules of C that you know about:
#include <stdio.h>
int main()
{
printf(“Braces come in pairs!”);
printf(“Comments come in pairs!”);
printf(“All statements end with a semicolon!”);
printf(“Spaces are optional!”);
printf(“Must have a main function!”);
printf(“C is done mostly in lowercase.\
It’s a case-sensitive language.”);
return(0);
}
Type the preceding source code into your editor. Save the code to disk as RULES.C. Compile and run.


The resulting program is named RULES, and you can run it whenever you need a reminder about some basic C do’s and don’ts.


This program is really no different from those shown in previous blog posts. It merely has more printf() functions.

The final printf() function (in Line 10) may seem a little odd. That’s because it’s split between two lines. This weird contraption is covered
later in later blog post.

See also:

Extra help in typing the GOODBYE.C source code

The compiler and the linker

How to compile goodbye.c?

Sponsor:DVDs Ripper

No comments:

Post a Comment