char *r = "1"; char *s = "23"; char *t = "456"; |
Write a short program that uses the sscanf() function to sum these 3 strings and print the result on stdout. (When you use sscanf(), you should check that it has successfully read a number.)
Modify the program in the previous exercise to read 3 strings from the command line. The number of command-line arguments should be checked.
Consider the following basic Makefile:
myprog: myprog.c myprog.h gcc -Wall -Werror -o myprog myprog.c |
CC=gcc CFLAGS=-Wall -Werror -O prog1: prog1.c prog1.h $(CC) $(CFLAGS) -o prog1 prog1.c prog2: prog2.c prog2.h $(CC) $(CFLAGS) -o prog2 prog2.c |
What happens when you execute the following commands (assume in each case that both source files have more recent timestamps)?
Extend the Makefile in 2 ways:
The UNIX command touch can be used to make the timestamp of a file the current time. For example, the command touch prog1.c will change the timestamp of prog1.c to the current time. Why is this a useful command in relation to make?
What will be the effect of the command touch *.c; make all?
Special macros, or abbreviations, are predefined in the Makefile. Two examples are:
Modify the Makefile so that the command uses these macros.