.so ref.tmac .TL .BI greet , an example C program .AU John Ankarström .AB This is the implementation of .I greet , a simple C program which greets the people supplied as arguments on the command line. .AE .Re greet.c:/^#include/ .LP First, we include all necessary libraries. .Re greet.c:/^main(/ .LP As the program's operation is quite simple, all its code will be contained in the .I main function. .Re greet.c:/^args:/ .LP This is where the main operation of the program takes place. At least one argument is required, in which case it is simply assigned to the .I people string. If multiple arguments are present, each is appended to the string in an intelligent way. At each iteration, it is made certain that the people string is large enough to contain the new name (and then some). .Re greet.c:/^concat:/ .LP If it is the last argument, the appendix is prefixed with the string " and ". Otherwise, unless it is the first argument, it is prefixed with a comma and a space. Then, the argument is appended to the .I people string. .Re greet.c:/^end:/ .LP Finally, the people are greeted. As the program ends here, there is no need to explicitly free the .I pepole string; the kernel will take care of it for us.