/* Program to print "hello, world" */ /* L Taber October 13, 1992 PCC */ /* Kernighan & Richie "The C Programming Language" */ /* Copyright 1978 page 6 */ #include <stdio.h> main() { printf("hello, world\n"); }
$ cc hello (cc is the C Compiler) $ link hello $ run hello (run the program) hello, world (resulting output)
/* Program to print arguments to a program */ /* L Taber March 28, 1993 PCC */ #include <stdio.h> main(argc, argv, env) int argc; char * argv[ ]; char * env[ ]; { int i; /* Print number of arguments and the first argument */ printf("argc = %d File name = %s\n", argc, argv[0]); /* Print all remaining arguments - if any */ for ( i=1; i<argc; i++) printf(" arg[%d] = %s \n" ,i,argv[i]); printf("\n"); /* Print the environment - if any */ for ( i=0; env[i] != NULL; i++) printf(" env[%d] = %s\n" ,i,env[i]); printf("\n"); }
RUN
command. The symbol
definition lets you run it without saying RUN
. If you use the
RUN
command you will not pass any arguments.
$ args :== $sys$login:args 'p1' 'p2' 'p3' ... 'p8'
ASSIGN SYS$OUTPUT
as a user mode logical name to C.OUT.
$ DEFINE /USER_MODE SYS$OUTPUT C.OUT
This time the output should be re-directed to a file (C.OUT), instead of your terminal. Redirect the output to your terminal with:$ args "This is number 1" and this is 2 to 7
$ DEASSIGN SYS$OUTPUT
Place the lab in the instructor hand-in box in BUS R6E, the "terminal room".Your-Name Lab 4.16: VAX C TABER CSC135