Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
tomershush authored Mar 5, 2021
1 parent c4ea57e commit 878f883
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
56 changes: 56 additions & 0 deletions colors.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <stdio.h>
#include <string.h>
#include "colors.h"

void redColor(char* word, char color)
{
char selectedColor[COLOR_LENGTH] = {'\0'};

switch (color)
{
case BLA:
strcat(selectedColor, BLACK);
break;

case R:
strcat(selectedColor, RED);
break;

case GR:
strcat(selectedColor, GREEN);
break;

case YEL:
strcat(selectedColor, YELLOW);
break;

case BLU:
strcat(selectedColor, BLUE);
break;

case MAG:
strcat(selectedColor, MAGENTA);
break;

case CY:
strcat(selectedColor, CYAN);
break;

default:
if (color == WHI)
{
strcat(selectedColor, WHITE);
}
else
{
strcat(selectedColor, RESET);
}
}
printf("%s", selectedColor);

while(*word != '\0')
{
printf("%c", *word++);
}
printf("%s", RESET);
}
26 changes: 26 additions & 0 deletions colors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef _COLORS_H_
#define _COLORS_H_

#define BLA 'B'
#define R 'r'
#define GR 'g'
#define YEL 'y'
#define BLU 'b'
#define MAG 'm'
#define CY 'c'
#define WHI 'w'

#define COLOR_LENGTH 7
#define BLACK "\x1b[30m"
#define RED "\x1b[31m"
#define GREEN "\x1b[32m"
#define YELLOW "\x1b[33m"
#define BLUE "\x1b[34m"
#define MAGENTA "\x1b[35m"
#define CYAN "\x1b[36m"
#define WHITE "\x1b[37m"
#define RESET "\x1b[0m"

extern void redColor(char* word, char color);

#endif
Binary file added colors.o
Binary file not shown.

0 comments on commit 878f883

Please sign in to comment.