63 char *formatted = malloc(
sizeof(message) +
sizeof(pcolor));
64 if (formatted == NULL) {
65 printf(
"failed to format colored string\n");
69 strcat(formatted, pcolor);
70 strcat(formatted, message);
98 size_t write_msg_size =
99 strlen(pcolor) + strlen(reset) + strlen(message) + 2;
100 char write_message[write_msg_size];
101 memset(write_message, 0, write_msg_size);
103 strcat(write_message, pcolor);
104 strcat(write_message, message);
105 strcat(write_message, reset);
106 strcat(write_message,
"\n");
108 int response = write(file_descriptor, write_message, strlen(write_message));
109 if (response == -1) {
110 printf(
"failed to write colored message\n");