|
Arguments to main |
Top Previous Next |
|
The standard declaration for a task’s main function is:
int main(int argc, char *argv[], char *envp[], CHAN * in_ports[], int ins, CHAN *out_ports[], int outs)
For example, a simple task might accept a stream of values on an input port representing characters, convert each character to upper case, and output the resulting stream of characters on an output port. The code for this is shown below; if you want to experiment you can find the source text in the file: <3L>My Designs\examples\Sundance\example-2\upc.c.
#include <chan.h> #include <ctype.h> #include <stdio.h> // for EOF
main(int argc, char *argv[], char *envp[], CHAN * in_ports[], int ins, CHAN *out_ports[], int outs) {
int c; for (;;) { chan_in_word(&c, in_ports[0]); if (c == EOF) break; // terminate task chan_out_word(toupper(c), out_ports[0]); } }
|