diff options
Diffstat (limited to 'map_count.c')
-rw-r--r-- | map_count.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/map_count.c b/map_count.c new file mode 100644 index 0000000..7c0167e --- /dev/null +++ b/map_count.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* map_count.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kdx <kdx @student.42angouleme.fr +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/10/14 14:33:55 by kdx #+# #+# */ +/* Updated: 2022/10/14 14:34:01 by kdx ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "map.h" + +size_t map_count(t_map *map, int v) +{ + size_t count; + size_t i; + + count = 0; + i = 0; + while (i < (map->width + 1) * map->height) + { + count += (map->data[i] == v); + i++; + } + return (count); +} |