Академический Документы
Профессиональный Документы
Культура Документы
Exercise1 - a
This exercise is created to demonstrates how extern works and what are the pitfalls
when using global variables.
1. Create a header named counter.h and declare extern g_counter.
2. Create new file named counter_handler_1.c:
Exercise1 - b
1. Create a header named counter.h and declare extern g_counter.
2. Create module counter_handler_1.c :
Include counter.h.
C Course Day 2
call
functions
init_counter(int
val)
and
Exercise 1 - c
1. Create new file named counter_handler_1.c:
and
call
functions
cnt_increment_1
and
Exercise 1 - d
1. Create new file named counter_handler_1.c:
C Course Day 2
Implement function cnt_increment_2(). It should increment counter by
two and print it to standard out.
call
functions
cnt_increment_1
and
Exercise 2
This exercise is created to show scope of variables. Build and run object_lifetime_e1.c
example. Comment behavior of variable x.
Modify object_lifetime_e1.c example so variable x is visible both in main() and foo()
functions. Remove foo() function parameter. Build and run example. Comment
behavior.
Exercise 3
Example demonstrates const qualifier usage in function parameter list. Comment lines
that are not allowed to be inside the functions in order to be able to build the
const_parameter.c code. Write down comments as function comments with in source
file.
modifyString1(const char *p)
modifyString1(char const *p)
modifyString1(char * const p)
modifyString1(const char const * p)
Explain why those lines can not be in these functions.
Exercise 4
Fix linkage error in linkage_error.c example.