summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosias <justjosias@tutanota.com>2020-04-22 15:50:22 +0300
committerJosias <justjosias@tutanota.com>2020-04-22 15:50:22 +0300
commit00cfff4484c09865636bc98a624a3c147b98d02e (patch)
tree94220b1f2c0852339ec69e3fd7b4d27bfe96c237
parent3326cf6334eebb7fd1e871148aaf8bdbf1710a0d (diff)
Improve spacing
-rw-r--r--rccat.c7
-rw-r--r--rccat.md7
2 files changed, 10 insertions, 4 deletions
diff --git a/rccat.c b/rccat.c
index 73b718d..5710b80 100644
--- a/rccat.c
+++ b/rccat.c
@@ -3,7 +3,9 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
+
#define BUF_SIZE 10
+
#define KNRM "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
@@ -21,7 +23,7 @@ void printColors(char *text)
if (!(isatty(STDOUT_FILENO))) {
printf("%s", text);
return;
- }
+ }
if (text) {
for (int i = 0; i < strlen(text); ++i) {
int color = 0;
@@ -34,6 +36,7 @@ void printColors(char *text)
}
printf("%s", KWHT);
}
+
int main(int argc, char *argv[])
{
srand(time(NULL));
@@ -61,6 +64,6 @@ int main(int argc, char *argv[])
fclose(fp);
}
}
-
+
return EXIT_SUCCESS;
}
diff --git a/rccat.md b/rccat.md
index b58243f..02c847f 100644
--- a/rccat.md
+++ b/rccat.md
@@ -8,9 +8,11 @@ Here is the basic structure of the program:
``` {.c file=rccat.c}
<<includes>>
+
<<constants>>
<<colors-function>>
+
<<main-function>>
```
@@ -29,6 +31,7 @@ Now for the includes:
Some constants that will be the same throughout the program:
``` {.c #constants}
#define BUF_SIZE 10
+
<<colors>>
```
@@ -68,7 +71,7 @@ If the output is piped (and thus isn't a tty), the colors don't make much sense.
if (!(isatty(STDOUT_FILENO))) {
printf("%s", text);
return;
-}
+}
```
Go through the text character by character and print it with a random color between 0 and 6 (the index of colors). It also makes sure that the color is not the same as the last one.
@@ -96,7 +99,7 @@ The main function that every C program must have.
int main(int argc, char *argv[])
{
<<main-body>>
-
+
return EXIT_SUCCESS;
}
```