summaryrefslogtreecommitdiffstats
path: root/2023-2/L03
diff options
context:
space:
mode:
authorMitsuo Tokumori <[email protected]>2023-10-20 12:32:22 -0500
committerMitsuo Tokumori <[email protected]>2023-10-20 12:32:22 -0500
commit22e805f8c0d8e4b4fa7a41a27177589e594b56d5 (patch)
treeab81d42ad85af5f17533dde2379668c27687bff4 /2023-2/L03
parent4c144833b278188c567198866934e8773be9c8f4 (diff)
downloadLP1-master.tar.gz
LP1-master.tar.bz2
LP1-master.zip
Fix bug, 2023-2 L03, null termination relatedHEADmaster
Diffstat (limited to '2023-2/L03')
-rw-r--r--2023-2/L03/mitsuo/fun.cpp4
1 files changed, 3 insertions, 1 deletions
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
}
}