2023-11-07 10:14:07 -05:00
|
|
|
/*
|
|
|
|
Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
|
|
|
|
|
|
|
|
Xhartae is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation.
|
|
|
|
And when you do redistribute it or modify it, it will use either version 3 of the License, or (at yours truly opinion) any later version.
|
|
|
|
It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3.
|
|
|
|
*/
|
|
|
|
|
2023-11-09 09:41:53 -05:00
|
|
|
#include "chapters/chapter_0.h"
|
|
|
|
#include "chapters/chapter_1.h"
|
|
|
|
#include "chapters/chapter_2.h"
|
|
|
|
|
2023-11-07 10:14:07 -05:00
|
|
|
/*
|
2023-11-09 09:41:53 -05:00
|
|
|
Maybe title (work in progress):
|
2023-11-07 10:14:07 -05:00
|
|
|
- The Great C & Practical Sailing
|
|
|
|
- The Ultimate C Programming Language Guide
|
|
|
|
- You Will Never Be A Book
|
|
|
|
- C: Disengage All Safety Protocols
|
|
|
|
|
|
|
|
About this "book":
|
|
|
|
|
|
|
|
This is the ultimate C programming language guide, brought to you by Ognjen 'xolatile' Milan Robovic. I'm not a native English speaker nor a real programmer, only a hobbyist, so
|
|
|
|
this "book" will be full of grammatical mistakes, but not compiler warnings. Please be patient, C is a small language, even for the time when it was made, so if you ignore my
|
|
|
|
rambling and focus on what's written outside of the comments, you'll easily learn it. Good luck and have fun...
|
|
|
|
|
|
|
|
Why should you learn or use C programming language in 2023?
|
2023-11-09 09:41:53 -05:00
|
|
|
|
2023-11-07 10:14:07 -05:00
|
|
|
- C was inspiration for many newer programming languages for good reasons.
|
|
|
|
- C can interface with huge variety of other distinct programming languages.
|
|
|
|
- C can be a lot more readable, faster and easier if used well.
|
|
|
|
|
2023-11-09 16:35:24 -05:00
|
|
|
One sane C program should have the following structure (please keep in mind that this is a book, not a sane program, thanks...):
|
2023-11-09 09:41:53 -05:00
|
|
|
|
2023-11-07 10:14:07 -05:00
|
|
|
0) Optional file, author or license information in comment.
|
|
|
|
1) Header guards and implementation definitions.
|
|
|
|
2) System header files then project header files.
|
|
|
|
3) Macro definitions.
|
|
|
|
4) Internal function then variable declarations.
|
|
|
|
5) External function then variable declarations.
|
|
|
|
6) Internal function then variable definition.
|
|
|
|
7) External function then variable definition.
|
|
|
|
8) Main function.
|
|
|
|
|
|
|
|
In C language, we have C source files with the extension '.c', and C header files with the extension '.h'. Both of those are just plain text files, and please use 7-bit ASCII
|
|
|
|
encoding, since it's common sense, UTF is cancer, and 8-bit ASCII is for enlightened people like Terrence Andrew Davis. C language is completely separate (on some C compilers)
|
|
|
|
from its' preprocessor, whose directives start with '#' character, continue on '\' character and break on '\n' (read: LINE FEED) character.
|
|
|
|
|
2023-11-09 09:41:53 -05:00
|
|
|
@C
|
2023-11-07 10:14:07 -05:00
|
|
|
#include <path/to/file/file_name.h> // Copy the entire file from '/usr/include/' directory into this file, on the place where it was specified.
|
|
|
|
#include "path/to/file/file_name.h" // Copy the entire file from current directory into this file, again on the place where it was specified.
|
|
|
|
|
|
|
|
#define SOMETHING // This will add additional information to the preprocessor about this file, it's mostly used for flags and header-guards.
|
|
|
|
#undef SOMETHING // This will remove that additional information you've provided...
|
|
|
|
|
|
|
|
#if SOMETHING //
|
|
|
|
#ifdef SOMETHING //
|
|
|
|
#ifndef SOMETHING //
|
|
|
|
#else //
|
|
|
|
#endif //
|
2023-11-09 09:41:53 -05:00
|
|
|
@
|
|
|
|
*/
|
2023-11-07 10:14:07 -05:00
|
|
|
|
|
|
|
int main (int argc, char * * argv) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
(void) argc;
|
|
|
|
(void) argv;
|
|
|
|
|
|
|
|
for (i = 0; i != (int) (sizeof (hello_world) / sizeof (* hello_world)); ++i) {
|
|
|
|
hello_world [i] ();
|
|
|
|
}
|
|
|
|
|
|
|
|
return (EXIT_SUCCESS);
|
|
|
|
}
|