|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/* Compile this program as:
gcc -std=c99 -Wall -Werror -pedantic -o rot rot.c
*/
#define ROT 13
static char rotate(char c)
{
.....
return c;
}
int main(int argc, char *argv[])
{
// check the number of arguments
if(argc != 2) {
....
exit(EXIT_FAILURE);
}
else {
....
exit(EXIT_SUCCESS);
}
return 0;
}
|
|
Of note in this example:
- Characters such as a space, tab, or newline, may appear almost
anywhere - they are stripped out and ignored by the C compiler.
We use such whitespace characters to provide a layout to our
programs.
While the exact layout is not important,
using a consistent layout is very good practice.
- Keywords, in bold, mean very specific things to the C compiler.
- Lines commencing with a '#'
in blue
are processed by a separate program,
named the C preprocessor.
In practice,
our program is provided as input to the preprocessor,
and the preprocessor's output is given to the C compiler.
- Lines in green
are comments.
They are ignored by the C compiler,
and may contain (almost) any characters.
C99 provides two types of comments -
- /* block comments */ and
- // comments to the end of a line
|