From 126fd0d3d6e3d2cfd4ed7d7e9fce94618b485a38 Mon Sep 17 00:00:00 2001 From: Joe Lukas Kalb Date: Tue, 6 Feb 2024 19:27:39 +0100 Subject: [PATCH] get_natural_number --- src/main/c/labyrinth.c | 7 +++++++ src/main/c/labyrinth.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/main/c/labyrinth.c b/src/main/c/labyrinth.c index bc3c05c..1d70380 100644 --- a/src/main/c/labyrinth.c +++ b/src/main/c/labyrinth.c @@ -14,6 +14,13 @@ void show_solution(Field_State** field, unsigned short len_x, unsigned short len } } +unsigned short get_natural_number(char text[]){ + unsigned short result; + printf("%s", text); + scanf("%hu", &result); + return result; +} + void turn_direction_right(Direction *direction){ switch (*direction) { case N: diff --git a/src/main/c/labyrinth.h b/src/main/c/labyrinth.h index 42c953a..593d111 100644 --- a/src/main/c/labyrinth.h +++ b/src/main/c/labyrinth.h @@ -9,5 +9,6 @@ void set_wall(Field_State** field, unsigned short x, unsigned short y); void init_field(Field_State** field, unsigned short len_x, unsigned short len_y); short lab_can_move(Field_State** field, unsigned short x, unsigned short y, Direction direction, unsigned short len_x, unsigned short len_y); void show_solution(Field_State** field, unsigned short len_x, unsigned short len_y); +unsigned short get_natural_number(char text[]); #endif // TEST_H