From 22e805f8c0d8e4b4fa7a41a27177589e594b56d5 Mon Sep 17 00:00:00 2001 From: Mitsuo Tokumori Date: Fri, 20 Oct 2023 12:32:22 -0500 Subject: Fix bug, 2023-2 L03, null termination related --- 2023-2/L03/mitsuo/fun.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to '2023-2') diff --git a/2023-2/L03/mitsuo/fun.cpp b/2023-2/L03/mitsuo/fun.cpp index 6f5fe0e..c3a4871 100644 --- a/2023-2/L03/mitsuo/fun.cpp +++ b/2023-2/L03/mitsuo/fun.cpp @@ -34,12 +34,14 @@ void lecturaDeProductos(const char *archivo, char ***&productos, int *&stocks, d } // memory allocation "por incrementos" - if (i == size) { + if (i + 1 >= size) { increase_size_productos(productos, stocks, precios, size); } productos[i] = crea_producto(code, description); // "code" is the "Primary Key" of the parallel arrays stocks[i] = qty; precios[i] = price; + + productos[i + 1] = NULL; /// last element of `productos` always points to NULL } } -- cgit v1.2.3