What is EOF
in the context of scanf
?
Hints:
man scanf | grep -A 1 -B 4 EOF
;
man scanf
and search for EOF;
What are standard input, standard output and standard error in
the context of POSIX programming?
Hints:
apropos standard | grep streams
;
man stdin
;
Where does the function printf
write to?
Where does the function scanf
read from?
How do you redirect the standard output of a program to a file?
How do you send the content of a file into a program's standard input?
How do you connect the standard output of a program to the standard input of another program?
What is the meaning of the following makefile variables:
$@
,
$<
,
$^
,
CFLAGS
,
LDFLAGS
,
LDLIBS
.
Hint: GNU make manual:
automatic variables,
implicit variables,
implicit rules.
What will the following makefile print (after running command
make
)
CFLAGS = -Wall -Ofast -std=c1x C = F all: echo CFLAGS echo $CFLAGS echo $(C)FLAGS echo $(CFLAGS)
Suppose you have your whole C-program in one file main.c
.
Which of the following makefiles will compile and link the
program into the executable file main
?
all: main
main: main.c
main: main.o
all: main main: main.o main.o: main.c
all: main main.o: main.c main: main.o
main.o: main.c all: main main: main.o
main: main.c cc main.c -o main
main: main.c $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
all: main main: main.o cc main.o -o main main.o: main.c cc -c main.c -o main.o
Suppose your main
function,
contained in the file main.c
, calls the functions
foo
and
bar
which are contained correspondingly in the files
foo.c
and
bar.c
.
Which of the following makefiles will correctly compile and link your
program into the executable file main
after the command
make
?
main: main.o foo.o bar.o
main: foo.o main.o bar.o
main: foo.o main.o bar.o cc foo.o main.o bar.o -o main
main: main.o foo.o bar.o $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
main: main.o foo.o bar.o main.o: main.c foo.o: foo.c cc -c $^ -o $@ bar.o: bar.c
main: main.o foo.o bar.o cc main.o foo.o bar.o -lm -o main main.o: main.c cc -c main.c foo.o: foo.c cc -c foo.c bar.o: bar.c cc -c bar.c
obj = main.o foo.o bar.o main: $(obj)
#define PI 3.1415927what is the effect of it?