From: Michał Bartoszkiewicz Date: Mon, 7 Dec 2009 00:56:08 +0000 (+0100) Subject: Dodanie „const” do stałych. X-Git-Tag: v1.0~6 X-Git-Url: https://git.bzium.org/embe/choinka.git/commitdiff_plain/07902d0dc79759db4894d0d83450b1169d082026?ds=sidebyside Dodanie „const” do stałych. --- diff --git a/choinka.c b/choinka.c index 62461df..1e29614 100644 --- a/choinka.c +++ b/choinka.c @@ -9,7 +9,7 @@ typedef struct { int kolor; } atrybut; -atrybut bombki[] = { +atrybut const bombki[] = { {A_BOLD, COLOR_RED}, {A_BOLD, COLOR_BLUE}, {A_BOLD, COLOR_YELLOW}, @@ -17,14 +17,14 @@ atrybut bombki[] = { {A_BOLD, COLOR_CYAN}, {A_BOLD, COLOR_WHITE}, }; -int ile_b = sizeof bombki / sizeof *bombki; +int const ile_b = sizeof bombki / sizeof *bombki; -atrybut choinka = {0, COLOR_GREEN}; -atrybut podstawa = {0, COLOR_YELLOW}; -atrybut podpis = {A_BOLD, COLOR_RED}; -atrybut gwiazdka = {A_BOLD, COLOR_YELLOW}; +atrybut const choinka = {0, COLOR_GREEN}; +atrybut const podstawa = {0, COLOR_YELLOW}; +atrybut const podpis = {A_BOLD, COLOR_RED}; +atrybut const gwiazdka = {A_BOLD, COLOR_YELLOW}; -char rysunek[] = +char const rysunek[] = " *\n" " /.\\\n" " /..'\\\n" @@ -52,11 +52,11 @@ int main() { srand(time(NULL)); setupterm(NULL, 1, NULL); - atrybut* kolor = &choinka; + atrybut const* kolor = &choinka; for (int i = 0; rysunek[i] != '\0'; i++) { char c = rysunek[i]; if (c == '[') kolor = &podstawa; - atrybut* akt = kolor; + atrybut const* akt = kolor; if (c >= 'a' && c <= 'z') akt = &podpis; if (c == '.') akt = &bombki[rand() % ile_b]; if (c == '*') akt = &gwiazdka;