diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-11-09 11:26:50 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-11-09 11:26:50 +0100 |
| commit | b799c007a1b6911fcbe5141429ea541e1277ebdd (patch) | |
| tree | d70ad0826ad2fc2d635adf9afecf89af0838d20b /cpp01/ex03/main.cpp | |
| parent | 1e9d90bdf9ef5fc05093d3449d883597c7f896de (diff) | |
| download | piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.tar.gz piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.tar.bz2 piscine_cpp-b799c007a1b6911fcbe5141429ea541e1277ebdd.zip | |
Fixing some edge cases in cpp00 and cpp01, Updated formatting
Diffstat (limited to 'cpp01/ex03/main.cpp')
| -rw-r--r-- | cpp01/ex03/main.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/cpp01/ex03/main.cpp b/cpp01/ex03/main.cpp index 20db57c..cef8577 100644 --- a/cpp01/ex03/main.cpp +++ b/cpp01/ex03/main.cpp @@ -6,25 +6,47 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/13 09:56:14 by charles #+# #+# */ -/* Updated: 2020/04/13 09:58:56 by charles ### ########.fr */ +/* Updated: 2020/11/09 10:57:25 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include <cstdlib> #include <iostream> +#include <fstream> #include "Zombie.hpp" #include "ZombieHorde.hpp" int main() { - srand(time(NULL)); + int seed; + std::ifstream devRandom("/dev/random"); + if (devRandom.is_open()) + { + devRandom.read((char*)&seed, sizeof(int)); + devRandom.close(); + } + else + seed = time(NULL); + srand(seed); - std::cout << "Stack horde" << std::endl; + std::cout << "=== Stack horde ===" << std::endl; ZombieHorde horde(5); horde.announce(); - std::cout << std::endl << "Heap horde" << std::endl; + std::cout << std::endl << "=== Heap horde ===" << std::endl; ZombieHorde *heap_horde = new ZombieHorde(7); heap_horde->announce(); delete heap_horde; + + std::cout << std::endl << "=== Empty horde ===" << std::endl; + ZombieHorde *empty_horde = new ZombieHorde(0); + empty_horde->announce(); + delete empty_horde; + + std::cout << std::endl << "=== Error horde ===" << std::endl; + ZombieHorde *negative_horde = new ZombieHorde(-13); + negative_horde->announce(); + delete negative_horde; + + return 0; } |
