diff options
author | John Ankarstr\xf6m <john@ankarstrom.se> | 2021-06-02 12:57:24 +0200 |
---|---|---|
committer | John Ankarstr\xf6m <john@ankarstrom.se> | 2021-06-02 14:14:13 +0200 |
commit | b61fcab3baf91ecd4b2ad4185e591cf339ad2b34 (patch) | |
tree | 9091676b4b07be854408b31e0be1b6d5eb5028e6 /greet.ms | |
download | ref-b61fcab3baf91ecd4b2ad4185e591cf339ad2b34.tar.gz |
First commit
Diffstat (limited to 'greet.ms')
-rw-r--r-- | greet.ms | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/greet.ms b/greet.ms new file mode 100644 index 0000000..58a8a55 --- /dev/null +++ b/greet.ms @@ -0,0 +1,48 @@ +.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. |