Table of Contents
Start the virtual machine and open a command terminal.
Answer individually to the following questions and check the answers with your lab partner:
What is the -o option used for?
Give an example of a warning that is only shown with the -Wall option.
How can you know the time it takes to execute a command?
If a program is invoked from the command interpreter
with the command program a b c d, What is the
value of the first parameter of the main
function?
Make sure you understand what is the effect of the
#include
, #define
and #ifdef
... #endif
directives.
Answer the following questions and check the answers with your lab partner before the lab session.
What is the difference between the directives
#include <file.h>
y #include
"file.h"
?
If program main.c
includes the
file main.h
, is the following command
correct?
$ gcc -o main main.c
What is the difference between the directive
#define SYMBOL
and #define SYMBOL
10
?
Suppose you need to have two versions of a program
that you wrote. The first version is used by you to detect errors
and the program prints on the screen all types of check
messages. The second version is for the customer and those messages
cannot appear. How would you achieve this with the
#ifdef
directive?
Prepare your virtual machine to work with a command terminal and the compiler.
Edit the files main.c
and
main.h
. Additionally to the #ifdef
directive,
the program uses the #ifndef
directive that is simply the
negation of the previous one. Create two executable versions, one that
prints msg1
and not msg2
, and another that
prints both messages.
printf
printf.c
file
Compile and execute the file
printf.c
.
Rewrite the format strings used in the
printf
function to produce the output with the following
format (do it without using more than two consecutive white
spaces):
The letter is m
The number is 60345698
The hexadecimal number is 0X3FA
The real number is 3.10e+33
The string is ABCDE