From 536dc5aca75083308d64c1176e28bc2a987956b7 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Thu, 2 May 2024 17:52:00 +0400 Subject: [PATCH] add comments bc i will forget what's going on --- The C Programming Language/1.10.c | 2 ++ The C Programming Language/1.11.c | 4 ++++ The C Programming Language/1.12.c | 2 ++ The C Programming Language/1.13.c | 2 ++ The C Programming Language/1.14.c | 2 ++ The C Programming Language/1.15.c | 2 ++ The C Programming Language/1.16.c | 3 +++ The C Programming Language/1.17.c | 2 ++ The C Programming Language/1.18.c | 2 ++ The C Programming Language/1.19.c | 2 ++ The C Programming Language/1.20.c | 2 ++ The C Programming Language/1.21.c | 2 ++ The C Programming Language/1.3.c | 2 ++ The C Programming Language/1.4.c | 1 + The C Programming Language/1.5.c | 2 ++ The C Programming Language/1.8.c | 2 ++ The C Programming Language/1.9.c | 2 ++ 17 files changed, 36 insertions(+) diff --git a/The C Programming Language/1.10.c b/The C Programming Language/1.10.c index 8d5d2b2..950a9e4 100644 --- a/The C Programming Language/1.10.c +++ b/The C Programming Language/1.10.c @@ -3,6 +3,8 @@ #define PRINT 0 #define SKIP 1 +// printing control chars + main() { int c; diff --git a/The C Programming Language/1.11.c b/The C Programming Language/1.11.c index 1496781..c709ecc 100644 --- a/The C Programming Language/1.11.c +++ b/The C Programming Language/1.11.c @@ -3,6 +3,10 @@ #define IN 1 #define OUT 0 +// counting words from getstream, +// doesn't work with backspace +// (by design) + main() { int c, nl, nw, nc, state; diff --git a/The C Programming Language/1.12.c b/The C Programming Language/1.12.c index 9d63cbb..1f62fa2 100644 --- a/The C Programming Language/1.12.c +++ b/The C Programming Language/1.12.c @@ -3,6 +3,8 @@ #define IN 1 #define OUT 0 +// converting input string to one word per line + main() { int c, state, word_ending; diff --git a/The C Programming Language/1.13.c b/The C Programming Language/1.13.c index 1a9c403..24f946e 100644 --- a/The C Programming Language/1.13.c +++ b/The C Programming Language/1.13.c @@ -2,6 +2,8 @@ #define MAX_AMOUNT_OF_LENGTHS 256 +// drawing chart of words lengths + main() { int c, i, j; diff --git a/The C Programming Language/1.14.c b/The C Programming Language/1.14.c index 62e821d..8463be8 100644 --- a/The C Programming Language/1.14.c +++ b/The C Programming Language/1.14.c @@ -2,6 +2,8 @@ #define MAX_AMOUNT_OF_LENGTHS 256 +// drawing chart of chars usage + main() { int c, i, j; diff --git a/The C Programming Language/1.15.c b/The C Programming Language/1.15.c index a53da8b..77990ca 100644 --- a/The C Programming Language/1.15.c +++ b/The C Programming Language/1.15.c @@ -1,5 +1,7 @@ #include +// creating a function to convert celsius to fahrenheit + double to_fahr(double celsius) { return (celsius * 9.0 / 5.0) + 32.0; diff --git a/The C Programming Language/1.16.c b/The C Programming Language/1.16.c index 88d96c9..961619d 100644 --- a/The C Programming Language/1.16.c +++ b/The C Programming Language/1.16.c @@ -2,6 +2,9 @@ #define MAXLINE 10 +// forcing getline to output actual amount of characters +// from input even if it exceedes MAXLINE boundary + int _getline(char line[], int maxline); void copy(char to[], char from[]); diff --git a/The C Programming Language/1.17.c b/The C Programming Language/1.17.c index 2efe276..30a6dd4 100644 --- a/The C Programming Language/1.17.c +++ b/The C Programming Language/1.17.c @@ -5,6 +5,8 @@ #define MAXTEXT 3000 #define SELECTION_LENGTH 10 +// output all strings that are longer than MAXLINE + int _getline(char line[], int maxline); int copy(char to[], int head, char from[]); diff --git a/The C Programming Language/1.18.c b/The C Programming Language/1.18.c index f216973..ad79f34 100644 --- a/The C Programming Language/1.18.c +++ b/The C Programming Language/1.18.c @@ -5,6 +5,8 @@ int _getline(char line[], int maxline); void trim(char to[], char from[], int from_head); +// remove all extra spaces and tabs from tail of input + main() { char line[MAXLINE]; diff --git a/The C Programming Language/1.19.c b/The C Programming Language/1.19.c index 6e68846..e2f429e 100644 --- a/The C Programming Language/1.19.c +++ b/The C Programming Language/1.19.c @@ -5,6 +5,8 @@ int _getline(char line[], int maxline); void reverse(char to[], char from[], int from_head); +// reversing input string + main() { int len; diff --git a/The C Programming Language/1.20.c b/The C Programming Language/1.20.c index 9db3a33..966db07 100644 --- a/The C Programming Language/1.20.c +++ b/The C Programming Language/1.20.c @@ -1,5 +1,7 @@ #include +// replacing tabs with spaces so it keeps indentation + int _getline(char s[], int lim) { int c, i, j; diff --git a/The C Programming Language/1.21.c b/The C Programming Language/1.21.c index c6dd7f2..b5eb16b 100644 --- a/The C Programming Language/1.21.c +++ b/The C Programming Language/1.21.c @@ -1,5 +1,7 @@ #include +// replacing empty strings consisting of only spaces +// to tabs and spaces so it keeps initial indentation int _getline(char s[], int lim) { diff --git a/The C Programming Language/1.3.c b/The C Programming Language/1.3.c index 26b5591..901a2fa 100644 --- a/The C Programming Language/1.3.c +++ b/The C Programming Language/1.3.c @@ -1,5 +1,7 @@ #include +// converting Fahrenheit to Celsius + main() { float fahr, celsius; diff --git a/The C Programming Language/1.4.c b/The C Programming Language/1.4.c index 231f85d..664142f 100644 --- a/The C Programming Language/1.4.c +++ b/The C Programming Language/1.4.c @@ -1,5 +1,6 @@ #include +// converting celsius to fahrenheit main() { float fahr, celsius; diff --git a/The C Programming Language/1.5.c b/The C Programming Language/1.5.c index 806e88b..fc88449 100644 --- a/The C Programming Language/1.5.c +++ b/The C Programming Language/1.5.c @@ -1,5 +1,7 @@ #include +// converting fahrenheit to celsius + main() { for (int fahr = 300; fahr >= 0; fahr = fahr - 20) diff --git a/The C Programming Language/1.8.c b/The C Programming Language/1.8.c index 979ff18..2a16c8f 100644 --- a/The C Programming Language/1.8.c +++ b/The C Programming Language/1.8.c @@ -1,5 +1,7 @@ #include +// counting spaces, tabs and newlines + main() { int c; diff --git a/The C Programming Language/1.9.c b/The C Programming Language/1.9.c index da10270..bbc56e0 100644 --- a/The C Programming Language/1.9.c +++ b/The C Programming Language/1.9.c @@ -3,6 +3,8 @@ #define NORMAL 0 #define SPACEBARING 1 +// trimming excessive spacebars down to one + main() { int c;