Real-time programming introductory exercises (year
97-98)
The following programs are only few lines of c- code. The first
gives You an idea how the UNIX- system call interface is documented. The
second exercise teach to You how to combine several source codes in a working
program and how to use UNIX- libraries. You can use GNU or HP c- compliler.
(1) Reading and understanding UNIX man-pages:
Write a c- program which reads a name of a UNIX- system
environment variable ( as "PATH" or "PS1".....) and
outputs the value of this variable.
Use the man page "getenv(3)"
( UNIX command line " man 3 getenv" )
If for example Your UNIX- command prompt is ">" and You give
the input "PS1" to Your program the output is ">".
(2) Compiling/header files/linking/separate modules/make- command/archives-
in the UNIX environment:
- See the man pages of :
- cc
- ld
- ar ( this command tells how to put modules to a program library)
- make (this command makes it possible to compile only changed parts
of Your program and tells to the compier how to build up a program from
different source files)
- Write a c- program which reads two integer numbers, adds them and outputs
the result.
- Adding in the SEPARATE MODULE (file "add.c"
)
- The prototype of adding in the file "add.h"
- Write a "make file"" for the program
- Compile the c- program
- Make the library ""mylib.a"", store "add.o""
to this library, compile the program
using the library