From ac5a7fa7810bfc4da78620c1b492123af7fd8c50 Mon Sep 17 00:00:00 2001 From: Francis Karuri <58594771+LUCASFRANKINC@users.noreply.github.com> Date: Thu, 15 Sep 2022 16:26:15 +0300 Subject: [PATCH] Update shuffle_array.c Since you are using the array pointer, just increment it in the loop and access the value in the address. --- algorithms/C/arrays/shuffle_array.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/algorithms/C/arrays/shuffle_array.c b/algorithms/C/arrays/shuffle_array.c index fa94cb1f..1bdacb02 100644 --- a/algorithms/C/arrays/shuffle_array.c +++ b/algorithms/C/arrays/shuffle_array.c @@ -33,8 +33,9 @@ void shuffle(int *array, int size) // Randomly shuffles given array void print_array(int *array, int size) // Printing array { - for (int i = 0; i < size; i++) { - printf("%d ", array[i]); + //PERF: Since you are using the array pointer, just increment it in the loop. + for (int i = 0; i < size; i++, array++) { + printf("%d ", *array); } putchar('\n'); }