check_valid_chars - 1Fr3aK2/Cub3d GitHub Wiki
📝 check_valid_chars
This function checks whether all characters in the map are valid according to a predefined set of allowed characters.
⚙️ Parameters
| Parameter | Type | Description |
|---|---|---|
map |
t_map* |
Pointer to the map structure to validate. |
🔁 Returns
| Return value | Description |
|---|---|
bool |
Returns true if all characters in the map are valid, false otherwise. |
📖 Description
The check_valid_chars function iterates through each element of the 2D map array and compares it against a predefined set of valid characters (VALID_CHARS).
- The function first checks if the map or the map array is
NULL, returningfalseif so. - It loops through each row and each character in the map.
- For each character, it checks whether it exists in the
VALID_CHARSarray. - If any character is not in the valid set, the function immediately returns
false. - If all characters are valid, the function returns
true.
💡 Example Usage
if (check_valid_chars(&map)) {
printf("All characters in the map are valid.\n");
} else {
printf("Map contains invalid characters.\n");
}