Week 5

Created by Miroslav Biňas / mirek

## Previously you Have Seen ```cpp struct person { char name[10]; char surname[20]; int age; // <-- WTF? char sex; // M, F }; ```
## Date and Time Representation
## Current Time now

Date and Time in a Structure

## Macros ```cpp #define SUNDAY 0 #define MONDAY 1 #define TUESDAY 2 #define WEDNESDAY 3 #define THURSDAY 4 #define FRIDAY 5 #define SATURDAY 6 ```
## Enumerated Type > is a data type consisting of a set of named values called **elements** (or members/enumerals/enumerators) of the type > ([Wikipedia](https://en.wikipedia.org/wiki/Enumerated_type))
```cpp enum days { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }; ```
```cpp enum days { SUNDAY, // 0 MONDAY, // 1 TUESDAY, // 2 WEDNESDAY, // 3 THURSDAY, // 4 FRIDAY, // 5 SATURDAY // 6 }; ```
![Playing Cards](../images/playing.cards.png) notes: * https://freesvg.org/royal-flush
```cpp enum suit { CLUB, DIAMONDS, HEARTS, SPADES }; ```
## Boolean Type ```cpp enum boolean { false, true }; ```
## Logging Levels ```cpp enum loglevel { DEBUG = 10, INFO = 20, WARNING = 30, ERROR = 40, CRITICAL = 50 }; ```

Unix Time

(seconds since 1 January 1970 00:00:00 UTC)

```cpp time_t time(time_t *tloc); ```
$$\frac{2^{32}}{2} + 1 = 2147483647$$

Judgement Day in

## Overflow
## Integer Overflow > occurs when an arithmetic operation attempts to create a numeric value that is outside of the range that can be represented with a given number of bits

(End of Time)

```cpp int main(int argc, char** argv); ```
## Exit Status
```bash $? ```
```cpp #include EXIT_SUCCESS // 0 EXIT_FAILURE // 1 ```
## Standard Streams
![Data Stream](../images/data.stream.png)
![Unix Standard Streams](../images/standard.streams.png)
```bash $ figlet "Hello world!" _ _ _ _ _ _ _ | | | | ___| | | ___ __ _____ _ __| | __| | | | |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | | | _ | __/ | | (_) | \ V V / (_) | | | | (_| |_| |_| |_|\___|_|_|\___/ \_/\_/ \___/|_| |_|\__,_(_) ```
## Stream Redirection ```bash figlet < input 1> output 2> error ```
## Example * `rev` - reverse lines characterwise * ```cpp $ echo "Hello world!" | rev !dlrow olleH ```
## Std. Streams in Linux * they are treated as files * they are defined in `stdio.h`: * `FILE* stdin` - as standard input * `FILE* stdout` - as standard output * `FILE* stderr` - as standard error output
## Handling Errors ```cpp fprintf( stderr, "Error: File 'words.txt' is missing." ); ```
## Questions?