summaryrefslogtreecommitdiff
path: root/web/tango-weevil/hello.tw
blob: b43f32f45d2923df24c449a636a9c3b62b37cf41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
\documentclass{article}
\usepackage{tw,makeidx}
\title{Hello World --- A Famous Program}
\author{Corey Minyard}
\date{\today}
\makeindex
\begin{document}
\maketitle
\section{Description}

This program is the famous ``hello world'' program.  Certainly we have
all written one of these programs.

\section{Code}

\subsection{Start Macro}
This is the main part of the program.
@code <*>
@<Includes>
@<Routines>
@endcode

\subsection{Includes}
This program needs \texttt{stdio.h} because it uses printf.
@code <Includes>
#include <stdio.h>
@endcode

\subsection{Routines}
This program only has one routine, the main routine.

@code <Routines>
@<main>
@endcode

\begin{twproc}{main}
\Description    The main routine.
\ReturnValues   \verb|int| - Program return code
\SideEffects	Well, it prints something!
\Inputs         \begin{twparmlist}
                \item[argc] Argument count
		\item[argv] The arguments
                \end{twparmlist}
\StartCode
@code <main>
int
main(int argc,
     char *argv)
{
   @<Output Hello>
   @<Leave Program>
}
@endcode

\subsection{Output Hello}
This macro actually does the output.
@code <Output Hello>
   printf("hello world\n");
@endcode

\subsection{Leave Program}
This macro causes the program to exit.
@code <Leave Program>
   exit(0);
@endcode
\end{twproc}

\printindex
\end{document}