CourseWare Wiki
Switch Term
Winter 2024 / 2025
Winter 2023 / 2024
Winter 2022 / 2023
Winter 2021 / 2022
Winter 2020 / 2021
Winter 2019 / 2020
Winter 2018 / 2019
Older
Search
Log In
b181
courses
be5b99cpl
labs
lab01
Warning
This page is located in archive. Go to the latest version of this
course pages
.
Differences
This shows you the differences between two versions of the page.
View differences:
Side by Side
Inline
Go
Link to this comparison view
Go
Go
courses:be5b99cpl:labs:lab01 [2018/10/04 15:47]
courses:be5b99cpl:labs:lab01 [2018/10/04 15:47]
(current)
Line 1:
Line 1:
+
====== Lab01 - Introduction to the Computer Laboratory and C Programming Language ======
+
+
* Introduction to the computer environment - password settings and eventually ownCloud setup
+
* Introduction to the working environment - terminal control and elementary commands: ''ls'', ''cd'', ''pwd'', ''mkdir'', ''cp'', ''mv'', ''rm'', ''touch'', and ''man''. Further commands such as ''locate'', ''cat'', ''hexdump'' and ''find''.
+
* Download souces from the 1st lecture {{courses:be5b99cpl:lectures:be5b99cpl-lec01-codes.zip|}}
+
* Compile the first program be5b99cpl-lec01-codes/program.c
+
<code>
+
clang -Wall -pedantic -std=c99 program.c -o main
+
</code>
+
Or
+
<code>
+
gcc -Wall -pedantic -std=c99 program.c -o main
+
</code>
+
* Compile and executed the program ''lec01/var.c''
+
* Setup your working environment, e.g.,
+
<code>
+
clang var.c && ./a.out
+
</code>
+
* Test to executed the program as in the lecture example
+
<code>
+
clang var.c -o var
+
./var
+
./var; echo $?
+
./var 1 2 3; echo $?
+
./var aaa; echo $?
+
</code>
+
* Compile the code with ''-E'' and ''-S'' options
+
* Evaluate the executable binary in dynamically and statically linked, use the ''strip'' tool to reduce the program size. Evaluate ''-OS'' compiler flag.
+
* Become familiar with your selected favorite editor for editing sources, e.g., gedit, sublime, vim.
+
For the ''gedit'', you cannot configure the formatting of the source according to the CPL recommendation coding style using ''clang-format'' using script available in the archive {{courses:be5b99cpl:labs:setup_gedit.zip|}}. You can download the archive, unzip the file, and execute the script as follows:
+
+
<code>
+
wget http://cw.fel.cvut.cz/wiki/_media/courses/be5b99cpl/labs/setup_gedit.zip
+
unzip setup_gedit.zip
+
./setup_gedit.sh
+
</code>
+
+
+
===== Lab tasks =====
+
+
* Test sizes of the numeric data types ''lec01/types.c'', ''lec01/points.c''
+
* Write simple macros for defining symbolic constant as a nested expression (using other macros).
+
* Evaluate the defined macros defined with and without enclosing brackets
+
* Become familiar with the program ''lec01/main_env.c''
+
* Write a simple program to parse a single value using ''scanf()'' and report message to ''stdout'' and ''stderr''
+
* Write a simple program to parse a sequence of numbers using ''scanf()'' and ''printf()'', read integer values and report average values computed to 2 decimal places.
+
* Write a program that reports information about the passed arguments to the program (''argc'', ''argv'')
+
* Write a simple program to read characters from ''stdin'' using ''getchar()'' and write them to ''stdout'' using ''putchar()''. Consider the program for copying files.
+
+
===== Further tasks =====
+
+
Implement programs in exercises and programming Projects of Chapters 2 and 3 of the K.K. King textbook.
courses/be5b99cpl/labs/lab01.txt
· Last modified: 2018/10/04 15:47 (external edit)