In: computer, programming, language.
C
C is a general-purpose computer programming language. It was created in the 1970s by Dennis Ritchie, and remains very widely used and influential. By design, C’s features cleanly reflect the capabilities of the targeted CPUs.
A successor to the programming language B, C was originally developed at Bell Labs by Ritchie between 1972 and 1973 to construct utilities running on Unix.
It was applied to re-implementing the kernel of the Unix operating system. During the 1980s, C gradually gained popularity. It has become one of the most widely used programming languages, with C compilers available for practically all modern computer architectures and operating systems.
https://wikipedia.org/wiki/C_(programming_language)
Compilers
The GNU C Library (glibc) manual:
https://sourceware.org/glibc/manual/html_mono/libc.html
GCC libC source code:
https://sourceware.org/git/?p=glibc.git;a=tree
GCC official manual:
https://gcc.gnu.org/onlinedocs/gcc
GCC source code:
https://gcc.gnu.org/git/?p=gcc.git;a=tree
Clang documentation:
https://clang.llvm.org/docs/UsersManual.html
Clang libC source code:
https://github.com/llvm/llvm-project/tree/main/libc
A C compiler written in Zig:
https://github.com/Vexu/arocc
https://aro.vexu.eu
Tiny C compiler reference documentation:
TCC mainly supports the i386 target on Linux and Windows
https://bellard.org/tcc/tcc-doc.html
Using C/C++ in Visual Studio Code:
https://code.visualstudio.com/docs/languages/cpp
Learning
C language reference:
https://en.cppreference.com/w/c
C language reference (as implemented in Microsoft C):
https://learn.microsoft.com/en-us/cpp/c-language/c-language-reference
https://learn.microsoft.com/en-us/cpp/c-language/ansi-conformance – ANSI conformance
https://learn.microsoft.com/en-us/cpp/cpp/fundamental-types-cpp – C++ builtin types
C language cheatsheet:
https://onecompiler.com/cheatsheets/c
Hyperpolyglot C vs Go
https://hyperpolyglot.org/c
W3 schools learn C:
-
https://w3schools.com/c/c_data_types.php – data types
-
https://w3schools.com/c/c_structs.php – structures
-
https://w3schools.com/c/c_pointers.php – pointers
-
https://w3schools.com/c/c_functions.php – functions
C programming language tutorial:
https://geeksforgeeks.org/c-programming-language
https://tutorialspoint.com/cprogramming
C standard library:
https://tutorialspoint.com/c_standard_library
comp.lang.c Frequently Asked Questions:
https://c-faq.com/index.html
-
Declarations and initializations
-
Structures, unions, and enumerations
-
Expressions
-
Pointers
-
Null Pointers
-
Arrays and pointers
-
Memory allocation
-
Characters and strings
-
Boolean expressions and variables
-
C preprocessor
-
ANSI/ISO standard C
-
STDIO
-
Library functions
-
Floating Point
-
Tools and Resources
Tiny C Projects, book & useful links:
https://c-for-dummies.com/tinyc
https://livebook.manning.com/book/tiny-c-projects
https://c-for-dummies.com/online – Courses
What’s the difference between malloc and calloc?
https://stackoverflow.com/questions/1538420/difference-between-malloc-and-calloc
calloc() gives you a zero-initialized buffer, while malloc() leaves the memory uninitialized
calloc = malloc + memset, pretty much
Use malloc() if you are going to set everything that you use in the allocated space
Use calloc() if you’re going to leave parts of the data uninitialized - and it would be beneficial to have the unset parts zeroed
In operating systems with optimistic memory allocation, like Linux, the pointer returned by malloc isn’t backed by real memory until the program actually touches it
calloc does indeed touch the memory (it writes zeroes on it) and thus you’ll be sure the OS is backing the allocation with actual RAM (or swap)
calloc is slower than malloc (not only does it have to zero it, the OS must also find a suitable memory area by possibly swapping out other processes)
Libraries
Common mathematical functions (in math.h & stdlib.h)
https://en.cppreference.com/w/c/numeric/math
Type-generic math (in tgmath.h)
https://en.cppreference.com/w/c/numeric/tgmath
File input/output (in stdio.h and wchar.h)
https://en.cppreference.com/w/c/io
Date and time utilities
https://en.cppreference.com/w/c/chrono
Pseudo-random number generation (in stdlib.h)
https://en.cppreference.com/w/c/numeric/random
Ultralightweight JSON parser in ANSI C (C89):
https://github.com/DaveGamble/cJSON
Ultra fast JSON decoder and encoder written in C with Python bindings:
https://github.com/ultrajson/ultrajson/tree/main/lib
A byte-oriented AES-256 implementation in C:
https://github.com/ilvn/aes256
https://github.com/limpkin/mooltipass/blob/master/source_code/src/AES
SHA-256 secure hash algorithm:
https://github.com/ilvn/SHA256
Binary-to-text encoding that is safe to pass through modern text processors
Alternative To: Base16 Base32 Base64 Ascii85
Implementations: Safe16 Safe32 Safe64 Safe80 Safe85
https://github.com/kstenerud/safe-encoding
Single-file public domain libraries for C/C++:
https://github.com/nothings/stb
-
image loader: stbimage.h
-
image writer: stbimagewrite.h
-
image resizer: stbimageresize2.h
-
font text rasterizer: stbtruetype.h
-
typesafe containers: stbds.h
Small library for working with Unicode in C
https://github.com/holepunchto/libutf
Parse streaming lines in C
https://github.com/holepunchto/libparseline
Cross-platform implementation of CRC32 with hardware acceleration
https://github.com/holepunchto/libcrc
BlurHash is a very compact representation of a placeholder for an image:
https://github.com/woltapp/blurhash
https://blurha.sh
Darknet is an open source neural network framework written in C and CUDA.
It is fast, easy to install, and supports CPU and GPU computation.
https://github.com/pjreddie/darknet
Genann is a minimal, well-tested library for training and using feedforward artificial neural networks (ANN) in C.
Its primary focus is on being simple, fast, reliable, and hackable.
It achieves this by providing only the necessary functions and little extra.
Genann is self-contained in two files: genann.c and genann.h.
https://github.com/codeplea/genann
Tinn (Tiny Neural Network) is a 200 line dependency free neural network library written in C99.
Tinn is great for embedded systems. Train a model on your powerful desktop and load it onto a microcontroller and use the analog to digital converter to predict real time events.
https://github.com/glouw/tinn