aboutsummaryrefslogtreecommitdiff
path: root/rush02/ex00/main.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-07-21 15:26:32 +0200
committerCharles <sircharlesaze@gmail.com>2019-07-21 15:26:32 +0200
commit23ad79e8b41c25bb4992d103d29a17612a52e351 (patch)
tree9de3cde07cc38e59f08885171e9f99eeab8ab71b /rush02/ex00/main.c
parent8b6e91bdb56bc01a588718472546f2a88e750b48 (diff)
downloadpiscine-23ad79e8b41c25bb4992d103d29a17612a52e351.tar.gz
piscine-23ad79e8b41c25bb4992d103d29a17612a52e351.tar.bz2
piscine-23ad79e8b41c25bb4992d103d29a17612a52e351.zip
c10 done, c11 on going, rush02 probably finished, bsq start
Diffstat (limited to 'rush02/ex00/main.c')
-rw-r--r--rush02/ex00/main.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/rush02/ex00/main.c b/rush02/ex00/main.c
new file mode 100644
index 0000000..14085f6
--- /dev/null
+++ b/rush02/ex00/main.c
@@ -0,0 +1,43 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* main.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: yiacono <yiacono@student.s19.be> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/07/20 07:25:21 by cacharle #+# #+# */
+/* Updated: 2019/07/21 15:02:43 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+#include "include.h"
+
+int main(int argc, char **argv)
+{
+ t_dict dict;
+ t_max_nbr nb;
+
+ if (print_error_if(argc > 3 || argc == 1, NULL))
+ return (1);
+ if (argc == 2)
+ {
+ dict = parse_dict_file("numbers.dict");
+ nb = strict_atoi(argv[1]);
+ }
+ if (argc == 3)
+ {
+ dict = parse_dict_file(argv[1]);
+ nb = strict_atoi(argv[2]);
+ }
+ if (print_error_if(nb == -1, dict))
+ return (1);
+ if (print_dict_error_if(dict == NULL || !required_values(dict)
+ || !as_uniq_keys(dict), dict))
+ return (1);
+ sort_dict(dict);
+ if (print_error_if(convert(nb, dict), dict))
+ return (1);
+ destroy_dict(dict, -1);
+ return (0);
+}