aboutsummaryrefslogtreecommitdiff
path: root/shifting_letters2.c
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-08-27 12:45:33 -0600
committerJack Sangdahl <[email protected]>2025-08-27 12:45:33 -0600
commit4552bcf5a4a356415e248dee3b201f0cea7205bb (patch)
tree9868465918c6a6841b84cd14d66923b993dd9d62 /shifting_letters2.c
parentf549305fb5ca531d29dce6c2c091560f44190443 (diff)
downloadleetcode-4552bcf5a4a356415e248dee3b201f0cea7205bb.tar.gz
leetcode-4552bcf5a4a356415e248dee3b201f0cea7205bb.zip
chore: Refactor two_d_arr_init function
Return a pointer to a new struct, rather than initialise objects in an existing struct
Diffstat (limited to 'shifting_letters2.c')
-rw-r--r--shifting_letters2.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/shifting_letters2.c b/shifting_letters2.c
index de20259..39deedc 100644
--- a/shifting_letters2.c
+++ b/shifting_letters2.c
@@ -38,11 +38,12 @@ int main() {
char *s1 = "abc", *s2 = "dztz";
int s1i[3][3] = {{0, 1, 0}, {1, 2, 1}, {0, 2, 1}},
s2i[2][3] = {{0, 0, 0}, {1, 1, 1}};
- struct two_d_arr sh1, sh2;
- two_d_arr_init(&sh1, 3, 3, s1i);
- two_d_arr_init(&sh1, 2, 3, s2i);
- printf("%s\n", shiftingLetters(s1, sh1.arr, sh1.row_size,
- sh1.col_size)); // expect: ace
- printf("%s\n", shiftingLetters(s2, sh2.arr, sh2.row_size,
- sh2.col_size)); // expect: catz
+ struct two_d_arr *sh1 = two_d_arr_init(3, 3, s1i);
+ struct two_d_arr *sh2 = two_d_arr_init(2, 3, s2i);
+ printf("%s\n", shiftingLetters(s1, sh1->arr, sh1->row_size,
+ sh1->col_size)); // expect: ace
+ printf("%s\n", shiftingLetters(s2, sh2->arr, sh2->row_size,
+ sh2->col_size)); // expect: catz
+ two_d_arr_free(sh1);
+ two_d_arr_free(sh2);
}