Make errors print to stderr instead of stdout
authorLukas Jiriste <ljiriste@student.42prague.com>
Tue, 5 Mar 2024 08:41:51 +0000 (09:41 +0100)
committerLukas Jiriste <ljiriste@student.42prague.com>
Tue, 5 Mar 2024 08:41:51 +0000 (09:41 +0100)
Libft
src/checker.c
src/push.c

diff --git a/Libft b/Libft
index 476d2fe6a4c2b0a53e1f68d5c26e8dbbac7359e2..db179cd200163de7d1cd25cc02b868edd0766cb2 160000 (submodule)
--- a/Libft
+++ b/Libft
@@ -1 +1 @@
-Subproject commit 476d2fe6a4c2b0a53e1f68d5c26e8dbbac7359e2
+Subproject commit db179cd200163de7d1cd25cc02b868edd0766cb2
index 4eda2069532bb6d61b6af8821e64e25cb11bc62c..eff49a5e9ad34016ae5cfde0e71756c7bd1d5ce9 100644 (file)
@@ -6,13 +6,14 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/01/24 10:31:06 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/03/01 10:07:26 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/03/05 09:40:36 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
 #include "push_swap.h"
 #include "libft.h"
 #include <stdlib.h>
+#include <unistd.h> // STDERR_FILENO
 
 #define COMMANDS_NUM 11
 
@@ -92,13 +93,13 @@ int main(int argc, char **argv)
        if (parse(argc, argv, &s.a))
        {
                clean_up(&s);
-               ft_printf("Error.\n");
+               ft_dprintf(STDERR_FILENO, "Error.\n");
                return (1);
        }
        if (interpret(&s))
        {
                clean_up(&s);
-               ft_printf("Error.\n");
+               ft_dprintf(STDERR_FILENO, "Error.\n");
                return (1);
        }
        if (is_sorted(&s.a) && s.b.stack.size == 0)
index 69f0ab516f72faba566a5a269e77b878c277763c..909bffd8cd23be4a1fe36589813f9dc5e9b11e05 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/01/24 13:17:32 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/03/01 12:43:14 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/03/05 09:40:03 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -18,6 +18,7 @@
 #include "push_swap.h"
 #include "libft.h"
 #include <stddef.h>
+#include <unistd.h> // STDERR_FILENO
 
 void   get_push_indeces(t_stacks *s, int *ind_a, int *ind_b)
 {
@@ -73,7 +74,7 @@ int   main(int argc, char **argv)
        if (parse(argc, argv, &s.a))
        {
                clean_up(&s);
-               ft_printf("Error.\n");
+               ft_dprintf(STDERR_FILENO, "Error.\n");
                return (1);
        }
        sort(&s);