<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.itcollege.ee/index.php?action=history&amp;feed=atom&amp;title=2016</id>
	<title>2016 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.itcollege.ee/index.php?action=history&amp;feed=atom&amp;title=2016"/>
	<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=2016&amp;action=history"/>
	<updated>2026-05-07T07:59:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=2016&amp;diff=124412&amp;oldid=prev</id>
		<title>Jtominga: Blanked the page</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=2016&amp;diff=124412&amp;oldid=prev"/>
		<updated>2017-09-25T22:28:03Z</updated>

		<summary type="html">&lt;p&gt;Blanked the page&lt;/p&gt;
&lt;a href=&quot;https://wiki.itcollege.ee/index.php?title=2016&amp;amp;diff=124412&amp;amp;oldid=124409&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Jtominga</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=2016&amp;diff=124409&amp;oldid=prev</id>
		<title>Jtominga: Created page with &quot; == Introduction==  === Lecturers === Rait Liiv: rait.liiv@itcollege.ee  Janno Tomingas: janno.tomingas@itcollege.ee  == C ==  === Lectures ===  ====== 1. Week. Introduction t...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=2016&amp;diff=124409&amp;oldid=prev"/>
		<updated>2017-09-25T22:26:55Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; == Introduction==  === Lecturers === Rait Liiv: rait.liiv@itcollege.ee  Janno Tomingas: janno.tomingas@itcollege.ee  == C ==  === Lectures ===  ====== 1. Week. Introduction t...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
== Introduction==&lt;br /&gt;
&lt;br /&gt;
=== Lecturers ===&lt;br /&gt;
Rait Liiv: rait.liiv@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
Janno Tomingas: janno.tomingas@itcollege.ee&lt;br /&gt;
&lt;br /&gt;
== C ==&lt;br /&gt;
&lt;br /&gt;
=== Lectures ===&lt;br /&gt;
&lt;br /&gt;
====== 1. Week. Introduction to C and C++ ======&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/854d0a23-530c-4b4e-a40a-94b4d613d0a1?ec=true&lt;br /&gt;
&lt;br /&gt;
====== 2. Week. Memory, pointers, datatypes ======&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/4c2fd365-3495-4175-a3cb-14b52a001e9e?ec=true&lt;br /&gt;
&lt;br /&gt;
====== 3. Week. Runtime, stack, heap (dynamic) memory, linker, declaration + definition ======&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/a4f70f62-3569-4abc-bf81-638ef9e0da7f?ec=true&lt;br /&gt;
&lt;br /&gt;
====== 4. Week. Stack, heap, pointer, jumps, typedef ======&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/8e0deb8d-ffab-4a0a-9456-78428674ccb3?ec=true&lt;br /&gt;
&lt;br /&gt;
=== Practices ===&lt;br /&gt;
&lt;br /&gt;
====== Practice 1 ======&lt;br /&gt;
Console input/output&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Write a program, that outputs &amp;quot;Hello, World!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2. Write a program, that asks the user for a number and then writes the number back to the user&lt;br /&gt;
&lt;br /&gt;
3. Write a simple calculator, that supports addition, subtraction, multiplication and division. The program should ask the user for two numbers and the operation to perform and output the result to the console.&lt;br /&gt;
&lt;br /&gt;
====== Practice 2 ======&lt;br /&gt;
Functions, pointers, out variables, function return values as success/error codes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;1. Write a function that adds two integers, outputs the result via an out variable and returns 0 to indicate a successful operation.&lt;br /&gt;
Hint:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
  int add(int a, int b, int* out)&lt;br /&gt;
  {&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;2. Write a function that swaps two integers and returns 0 to indicate a successful operation.&lt;br /&gt;
Hint:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
  int swap(int* a, int* b)&lt;br /&gt;
  {&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;3. Write a function that reverses a string and returns 0 to indicate a successful operation.&lt;br /&gt;
Hint:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
  int reverse(char* string, size_t length)&lt;br /&gt;
  {&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;4. Write a function that sorts an array of ints and returns 0 to indicate a successful operation.&lt;br /&gt;
Hint:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
  int sort(int* string, size_t length)&lt;br /&gt;
  {&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Practice 3 ======&lt;br /&gt;
File input/output, dynamic memory allocation&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;1. Write a program that outputs the contents of a text file into the console.&lt;br /&gt;
Hint:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
Always close the file stream after you are done using it.&lt;br /&gt;
&lt;br /&gt;
Make sure to check for error codes.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;2. Write a program that reads the contents of a text file into a dynamically sized array and outputs the information into a new file.&lt;br /&gt;
Hint:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
Use &amp;quot;fseek&amp;quot;, &amp;quot;ftell&amp;quot; and &amp;quot;rewind&amp;quot; to find out how large the buffer should be.&lt;br /&gt;
&lt;br /&gt;
Make sure you have enough room for a null terminator.&lt;br /&gt;
&lt;br /&gt;
Remember to free the allocated memory after calling malloc or calloc.&lt;br /&gt;
&lt;br /&gt;
Make sure to check for error codes.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Practice 4 ======&lt;br /&gt;
Dynamic memory allocation continued, structs, .h/.c files&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Create an implementation of a stack data structure ([https://en.wikipedia.org/wiki/Stack_(abstract_data_type) Stack (abstract data type)]) that uses a dynamically allocated array for storage.&lt;br /&gt;
* Required functions:&lt;br /&gt;
** init - Initializes stack&amp;#039;s variables and allocates required dynamic memory with an initial(default) size,&lt;br /&gt;
** destroy - Frees all allocated memory and optionally resets other stored information for a stack,&lt;br /&gt;
** push - Adds an element to the top of the stack,&lt;br /&gt;
** peek - Gets the top element of the stack,&lt;br /&gt;
** pop - Gets and removes the top element of the stack;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Describe the stack struct and functions in a separate .h file,&lt;br /&gt;
* Implement the functions in a corresponding .c file,&lt;br /&gt;
* Test your stack with some operations. Remember to check for edge cases;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;Hints:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
*How do you know which element to access?&lt;br /&gt;
*How do you know if an array is full?&lt;br /&gt;
*How should the functions behave when a stack is empty?&lt;br /&gt;
*How should the functions behave when a stack is full?&lt;br /&gt;
*What will happen if any of the functions are called unexpectedly many times?&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Assignment ===&lt;br /&gt;
Write a program that reads values from a file and outputs the result to stdout.&lt;br /&gt;
&lt;br /&gt;
====== Input ======&lt;br /&gt;
Input file&amp;#039;s name is &amp;quot;input.txt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The file contains index-value pairs of integers on a single line. Integers in a pair are separated with a comma (,) and pairs are separated with a semicolon (;).&lt;br /&gt;
&lt;br /&gt;
All indices between 0 and (count_of_pairs - 1) are guaranteed to be present.&lt;br /&gt;
&lt;br /&gt;
The indices are guaranteed to be unique.&lt;br /&gt;
&lt;br /&gt;
The indices are not guaranteed to appear in an ascending order.&lt;br /&gt;
&lt;br /&gt;
Sample input:&lt;br /&gt;
1,4;0,2;2,8&lt;br /&gt;
&lt;br /&gt;
====== Output ======&lt;br /&gt;
The program should output the differences between consecutive values as the index increases.&lt;br /&gt;
&lt;br /&gt;
Output should be printed as a comma separated list of values on a single line to stdout.&lt;br /&gt;
&lt;br /&gt;
For input:&lt;br /&gt;
 0,1;2,4;1,2&lt;br /&gt;
&lt;br /&gt;
Calculates:&lt;br /&gt;
 0,1 to 1,2 -&amp;gt; 2 - 1 = 1&lt;br /&gt;
 1,2 to 2,4 -&amp;gt; 4 - 2 = 2&lt;br /&gt;
&lt;br /&gt;
And outputs:&lt;br /&gt;
 1,2&lt;br /&gt;
&lt;br /&gt;
====== Examples ======&lt;br /&gt;
 -&amp;gt;&lt;br /&gt;
 0,2 -&amp;gt; 0&lt;br /&gt;
 1,2;0,1 -&amp;gt; 1&lt;br /&gt;
 1,4;0,2;2,8 -&amp;gt; 2,4&lt;br /&gt;
 1,4;0,2;2,-2 -&amp;gt; 2,-6&lt;br /&gt;
&lt;br /&gt;
== C++ ==&lt;br /&gt;
&lt;br /&gt;
=== Lectures C++ ===&lt;br /&gt;
&lt;br /&gt;
====== 5, 6, 7 Week. C++, class, namespace, new + delete, reference, libraries, bool. ======&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/6b331ce5-dcc9-4bbf-a490-13d40bef2812?ec=true&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/4c009949-e8b4-43a0-adc0-8ed055baf7b9?ec=true&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/f994eebc-39c8-4ea8-8056-d358d89b329c?ec=true&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== 8. Week. Const. + Additional leftover from previous lectures. ======&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/95e5962a-3d0b-489f-a759-86dd7a29f2ef?ec=true&lt;br /&gt;
&lt;br /&gt;
====== 9. Week. Templates ======&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/7f7c58b8-8173-42a4-8b9a-a3941196376a?ec=true&lt;br /&gt;
&lt;br /&gt;
====== 10. Week. Iterator, Casting, ======&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/bfec4cef-6c38-46c0-9e06-1da985d94a66?ec=true&lt;br /&gt;
&lt;br /&gt;
====== 11. Week. Static, Smart pointers, RAII ======&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/1b6f336e-52b8-4993-8c6f-de0cd5eb8a49?ec=true&lt;br /&gt;
&lt;br /&gt;
====== 12. Week. Exception, Assembly language ======&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/c093e098-f789-4600-8b5c-f7995b3abfcb?ec=true&lt;br /&gt;
&lt;br /&gt;
=== Practices ===&lt;br /&gt;
&lt;br /&gt;
====== Practice 1 ======&lt;br /&gt;
Console input/output, strings, references, arrays, new/delete&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;1. Write a simple calculator, that takes a simple binary operation (+,-,*,/) as an input and outputs the result to the console on a new line.&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
  1 + 2 -&amp;gt; 3&lt;br /&gt;
  3 * 8 -&amp;gt; 24&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;2. Write a program that asks the user for several strings and outputs the total numbers of characters entered.&lt;br /&gt;
* Ask for the number of strings the user will enter,&lt;br /&gt;
* Store all input strings in in an appropriately sized array,&lt;br /&gt;
* Use a function to count the total number of characters entered;&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
Input:&lt;br /&gt;
 3&lt;br /&gt;
 one&lt;br /&gt;
 two&lt;br /&gt;
 three&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
 11&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====== Practice 2 ======&lt;br /&gt;
Classes, constructors/destructors, member functions, intro to templates, vector&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Create a class Rectangle, that:&lt;br /&gt;
* Stores the width and height as private member variables,&lt;br /&gt;
* Uses a constructor to set width and height,&lt;br /&gt;
* Has public member functions to calculate and return the area and circumference of the rectangle;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Create a program that uses std::vector to store several Rectangles and computes the total area of all stored rectangles.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Convert the stack (Practice 4 of C) from C to C++:&lt;br /&gt;
* Replace the struct with a class,&lt;br /&gt;
* Add member functions,&lt;br /&gt;
* Make use of constructors and destructors,&lt;br /&gt;
* Adjust member functions to return values on success (and, for the bold, throw on failure),&lt;br /&gt;
* Use a class template to describe the datatype stored in the struct;&lt;br /&gt;
&lt;br /&gt;
====== Practice 3 ======&lt;br /&gt;
Inheritance, dynamic polymorphism, unique_ptr&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Create classes Rectangle and Circle, that:&lt;br /&gt;
* Store necessary data as private member variables,&lt;br /&gt;
* Have a public member function to calculate and return their area;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Create a program, that:&lt;br /&gt;
* Creates and stores some Rectangles and Circles,&lt;br /&gt;
* Calculates the total area of the shapes;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Create a base class for previously created objects, called Shape:&lt;br /&gt;
* Create a public virtual member function area,&lt;br /&gt;
* Create a protected member variable to store the number of a Shape&amp;#039;s corners in,&lt;br /&gt;
* Modify both Rectangle and Circle to inherit Shape and override the virtual function,&lt;br /&gt;
* Modify your program to store Shapes in a vector of unique pointers to Shape;&lt;br /&gt;
&lt;br /&gt;
[https://wiki.itcollege.ee/index.php/Basics_of_C/C%2B%2B_Programming_Practice_7_Code Sample code]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Add a class Triangle, that inherits from Shape:&lt;br /&gt;
* Store the necessary data,&lt;br /&gt;
* Create the necessary functions,&lt;br /&gt;
* Use all the Shapes in your program;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Add a function to calculate the Shapes&amp;#039; circumference.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. (optional) Similarly to the Shapes, create a hierarchy of Animals, that:&lt;br /&gt;
* Know their name,&lt;br /&gt;
* Can write out the sound they make;&lt;br /&gt;
&lt;br /&gt;
Use your Animals in a simple program.&lt;br /&gt;
&lt;br /&gt;
====== Practice 4 ======&lt;br /&gt;
Overloading, template functions, template classes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Create a new header file:&lt;br /&gt;
* Create a function add - int add (int a, int b),&lt;br /&gt;
* Create separate implementations of the add function for floats, doubles, and strings,&lt;br /&gt;
* Try out the functions;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Template the add function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Create a simple templated Queue ([https://en.wikipedia.org/wiki/Queue_(abstract_data_type) Queue (abstract data type)]), that:&lt;br /&gt;
* Uses a container to store the items in,&lt;br /&gt;
* Has a member function to add items to the queue (enqueue),&lt;br /&gt;
* Has a member function to get items from the queue (dequeue);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Create a template class Accumulator, that:&lt;br /&gt;
* Stores an instance of the templated type as a member variable,&lt;br /&gt;
* Sets the initial value of the variable via the constructor,&lt;br /&gt;
* Has a member function to add to the stored value,&lt;br /&gt;
* Has a member function to retrieve stored value;&lt;br /&gt;
You may assume the templated type is not a pointer and has operator+= defined.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. (optional, self-research) Create a class Distance, that can be used with the Accumulator:&lt;br /&gt;
* Store the value in a member variable,&lt;br /&gt;
* Overload operator+= to support addition between two instances of the Distance class,&lt;br /&gt;
Additional information on operators and operator overloading can be found at [http://en.cppreference.com/w/cpp/language/operators operator overloading].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Practice 5 ======&lt;br /&gt;
Function pointers, lambdas, std::function&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Create a function that counts the number of odd numbers in a container of ints:&lt;br /&gt;
* Implement the function,&lt;br /&gt;
* Store the function pointer in a variable,&lt;br /&gt;
* Use the function;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Create a lambda that returns the position of the first negative number in a container of ints:&lt;br /&gt;
* Implement the lambda,&lt;br /&gt;
* Store the lambda in a variable,&lt;br /&gt;
* Use the lambda;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Create a lambda that calculates the factorial of an int:&lt;br /&gt;
* Implement the lambda capturing the number by value,&lt;br /&gt;
* Use the lambda;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Create a lambda that adds all non-negative numbers in a previously defined container of ints:&lt;br /&gt;
* Implement the lambda capturing the container by reference,&lt;br /&gt;
* Use the lambda;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Create a function zero_if, that:&lt;br /&gt;
* Takes a reference to container of ints as its first argument,&lt;br /&gt;
* Takes a comparison function as its second argument (has an integer as its parameter and returns a bool),&lt;br /&gt;
* Returns void,&lt;br /&gt;
* If the comparison function returns true for an int, sets its value to 0;&lt;br /&gt;
When zeroing all odd numbers in a vector&lt;br /&gt;
  [1, 2, 3, 4, 5]&lt;br /&gt;
The function should return&lt;br /&gt;
  [0, 2, 0, 4, 0]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Use the created function with newly created lambdas and functions.&lt;br /&gt;
Sample usage might be to zero all negative integers in a vector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Practice 6 ======&lt;br /&gt;
STL Algorithms, lambdas in use&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Find the largest element in a container of ints.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
2. Sort a vector of ints using:&lt;br /&gt;
* Sort the container into ascending order,&lt;br /&gt;
* Provide a custom Compare function to sort the vector into descending order;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. From a vector of ints remove all negative values (erase-remove):&lt;br /&gt;
* Use std::remove_if to move all elements to be deleted to the end of the vector,&lt;br /&gt;
* Use the vector erase method to delete all the elements from the vector;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. From a vector of strings count the number of strings, that have a length greater than 5 characters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. From a vector of strings remove all strings that have a length under 3 characters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Reverse all strings in a vector of strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====== Practice 7 ======&lt;br /&gt;
Using external libraries&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Download [http://www.sfml-dev.org/ SFML] and create a new project&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;&amp;#039;&amp;#039;&amp;#039;Setting up the include and library directories:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;Useful shorthand macros:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
  $(SolutionDir) - Points to the directory where your solution file (.sln) is located&lt;br /&gt;
&lt;br /&gt;
  $(ProjectDir) - Points to the directory where your project file (.vcxporoj) is located&lt;br /&gt;
&lt;br /&gt;
  $(ENV_VAR) - Points to wherever a user variable or system variable points to, where ENV_VAR is the name of that variable&lt;br /&gt;
&lt;br /&gt;
A full list of currently available environment variables can be found by pressing the &amp;quot;Macros&amp;gt;&amp;gt;&amp;quot; button when editing project include or library directories.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;Include directories:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
* Make sure you have at least one .cpp file in your project.&lt;br /&gt;
* Go to Project -&amp;gt; Properties -&amp;gt; C/C++ -&amp;gt; General.&lt;br /&gt;
* Edit Additional Include Directories.&lt;br /&gt;
* Add an entry that points to the SFML include directory.&lt;br /&gt;
* If the previous steps were performed successfully, you should be able to include the SFML header files in your files (#include &amp;quot;SFML/Window.hpp&amp;quot;)&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;Library directories:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
* Go to Project -&amp;gt; Properties -&amp;gt; Linker -&amp;gt; General.&lt;br /&gt;
* Edit Additional Library Directories.&lt;br /&gt;
* Add an entry that points to the SFML Libs/Release directory.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;.lib files:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
* Go to Project -&amp;gt; Properties -&amp;gt; Linker -&amp;gt; Input.&lt;br /&gt;
* For each SFML module that you use, add the required .lib files to the Additional Dependencies list (System.hpp requires sfml-system.lib). The dependencies for each module can be found at the [http://www.sfml-dev.org/faq.php#build-link SFML FAQs]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible mw-collapsed&amp;quot;&amp;gt;.dll files:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
* For every .lib file that you use, find and copy the corresponding .dll file from the SFML/bin folder into the folder where your program&amp;#039;s .exe file will be built to. (sfml-system.lib -&amp;gt; sfml-system-2.dll)&lt;br /&gt;
* The default build target directory will be the Debug folder under your solution directory.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. Create an empty window and an initial game loop.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Draw a white rectangle somewhere on the window.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Handle keyboard arrow events to move the rectangle around.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create a simple snake game.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Simulate the movement of the snake:&lt;br /&gt;
* Divide the window in a grid to help with movement and collision detection,&lt;br /&gt;
* After each frame, draw a new rectangle to the right from the old one,&lt;br /&gt;
* Make it possible to change the &amp;quot;moving&amp;quot; direction with arrow keys,&lt;br /&gt;
* Do not let the rectangle leave the screen, have it wrap around to the opposite edge instead;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Add the tail:&lt;br /&gt;
* Keep track of how long the snake should be,&lt;br /&gt;
* Start with having one rectangle in a container (for example an std::deque),&lt;br /&gt;
* Add the new rectangle (see part 4) to the start of the container each turn,&lt;br /&gt;
* Remove the last rectangle once the tail grows too long;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Add collision checking:&lt;br /&gt;
* Once the first rectangle (head of the snake) overlaps with either food or its tail, perform an action,&lt;br /&gt;
* If the head overlaps with tail, end the game,&lt;br /&gt;
* If the head overlaps with food, grow the tail;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Add food:&lt;br /&gt;
* At the start of the game, spawn the food at a random unoccupied location on the screen,&lt;br /&gt;
* When the snake eats the food, spawn more food;&lt;br /&gt;
&lt;br /&gt;
=== Assignment ===&lt;br /&gt;
Implement [https://en.wikipedia.org/wiki/Conway&amp;#039;s_Game_of_Life Conway&amp;#039;s Game of Life] using C++ and SFML.&lt;br /&gt;
&lt;br /&gt;
See Practice 7 for an example of how to set up the project.&lt;br /&gt;
&lt;br /&gt;
====== General info ======&lt;br /&gt;
The game consists of a grid of cells. Each cell is either alive or dead. Every cell interacts with its eight adjacent cells.&lt;br /&gt;
&lt;br /&gt;
Before the start of the game, the user can select which cells are alive or dead.&lt;br /&gt;
&lt;br /&gt;
The user can not change the states of the cells while the automation is running.&lt;br /&gt;
&lt;br /&gt;
Once the game is started, the states of the cells in the next frame are calculated for all cells in the grid based on the following rules:&lt;br /&gt;
* If a live cell has fewer than two live neighbours, it dies,&lt;br /&gt;
* If a live cell has two or three live neighbours, it lives,&lt;br /&gt;
* If a live cell has more than five live neighbours, it dies,&lt;br /&gt;
* If a dead cell has three live neighbours, it becomes alive;&lt;br /&gt;
&lt;br /&gt;
The game calculates and displays new frames until the automation is stopped.&lt;br /&gt;
&lt;br /&gt;
====== Example usage ======&lt;br /&gt;
The user starts up the program and selects some cells to be alive.&lt;br /&gt;
&lt;br /&gt;
The user presses a key to start the game.&lt;br /&gt;
&lt;br /&gt;
The automation runs until the user presses a key to end the game or closes the program.&lt;br /&gt;
&lt;br /&gt;
== Exploits ==&lt;br /&gt;
&lt;br /&gt;
=== Lectures ===&lt;br /&gt;
&lt;br /&gt;
====== 12. Week. Exception, Assembly language ======&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/c093e098-f789-4600-8b5c-f7995b3abfcb?ec=true&lt;br /&gt;
&lt;br /&gt;
====== 13. Week. Discussion about vulnerabilities and exploiting. ======&lt;br /&gt;
&lt;br /&gt;
https://echo360.e-ope.ee/ess/echo/presentation/e479b230-24a1-48d4-bbb1-a4621e1231ac?ec=true&lt;br /&gt;
&lt;br /&gt;
=== Practices ===&lt;br /&gt;
&lt;br /&gt;
====== Practice 1 ======&lt;br /&gt;
Assembly language&lt;br /&gt;
&lt;br /&gt;
Setting up your environment:&lt;br /&gt;
* Create a new empty project,&lt;br /&gt;
* Add a main.cpp file,&lt;br /&gt;
* Under project &amp;quot;Properties -&amp;gt; C/C++ -&amp;gt; Code Generation&amp;quot; set Security Check to Disable Security Check;&lt;br /&gt;
&lt;br /&gt;
To view disassembly:&lt;br /&gt;
* While debugging your program, open the disassembly window at Debug -&amp;gt; Windows -&amp;gt; Disassembly;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Create an integer variable i:&lt;br /&gt;
* Assign a value to i,&lt;br /&gt;
* Add 1 to i,&lt;br /&gt;
* Inspect the resulting assembly instructions;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Using what you have learned:&lt;br /&gt;
* Create an integer variable a,&lt;br /&gt;
* Using assembly, assign a value to a,&lt;br /&gt;
* Using assembly, add 1 to a,&lt;br /&gt;
* Verify, that the resulting value is correct;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Create a character array c to hold 3 characters:&lt;br /&gt;
* Fill in the array one by one,&lt;br /&gt;
* Inspect the resulting assembly instructions;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Using what you have learned:&lt;br /&gt;
* Create a integer array d to hold 2 ints,&lt;br /&gt;
* Using assembly, fill the array with data,&lt;br /&gt;
* Verify, that the array is filled with expected values;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Create a simple if:&lt;br /&gt;
* Subtract 1 from int i if i is equal to 2,&lt;br /&gt;
* Inspect the resulting assembly instructions;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Using what you have learned:&lt;br /&gt;
* Create an if conditional, that subtracts 1 from int a if int i and a are equal,&lt;br /&gt;
* Verify, that the conditional works as expected;&lt;br /&gt;
&lt;br /&gt;
====== Practice 2 ======&lt;br /&gt;
Assembly language continued, stack smashing&lt;br /&gt;
&lt;br /&gt;
1. Create a function that takes no arguments&lt;br /&gt;
* Call the function&lt;br /&gt;
* Inspect the resulting assembly instructions;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. Using what you have learned:&lt;br /&gt;
* Call the function using assembly,&lt;br /&gt;
* Verify that the function gets called;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Create an add function:&lt;br /&gt;
* The function should return the result of adding two integers passed in as parameters,&lt;br /&gt;
* Call the function and store the result in a variable,&lt;br /&gt;
* Inspect the resulting assembly instructions;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Using what you have learned:&lt;br /&gt;
* Create a subtract function,&lt;br /&gt;
* Use assembly to call the subtract function with different values and store the result in a variable,&lt;br /&gt;
* Verify, that the function call works as expected and that the value gets stored;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Create a function that internally holds an array of only one void* and takes a void* as a parameter:&lt;br /&gt;
* Write over the bounds of the array and observe what happens,&lt;br /&gt;
* Try passing different pointers to the function;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Assignment ===&lt;br /&gt;
Do some research on vulnerabilities related to the following topics:&lt;br /&gt;
&lt;br /&gt;
* Buffer overflow (stack smashing, code injection, arc injection),&lt;br /&gt;
* Arithmetic over-/underflow,&lt;br /&gt;
* Memory leaks,&lt;br /&gt;
* Double free (and double delete),&lt;br /&gt;
* Formatted output,&lt;br /&gt;
* Concurrency,&lt;br /&gt;
* File I/O (symlinks, hardlinks);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Write an essay, that describes the causes, examples, and mitigation strategies for all of the topics.&lt;/div&gt;</summary>
		<author><name>Jtominga</name></author>
	</entry>
</feed>