Arrays in C: Declare, Initialize, Loop and Pass Arrays to Functions
A beginner-first guide to arrays in C, with tested programs for test scores, temperatures, a playlist and a cinema seat map.
C is one of the most important programming languages ever created. Developed in the early 1970s, it remains the foundation of operating systems, embedded systems, compilers, and high-performance software used across the world today. Learning C gives you a deep understanding of how computers actually work — memory, pointers, data structures, and low-level system operations that higher-level languages hide from you.
At MYCPLUS we have been publishing C programming tutorials, source code examples, and practical guides since 2004. Whether you are writing your first Hello World program or working through complex data structure implementations, this section covers every stage of the C learning journey. You will find step-by-step tutorials, working source code you can compile and run immediately, and clear explanations of concepts that are often poorly explained elsewhere.
C is the language that powers Linux, Windows internals, embedded microcontrollers, game engines, and countless performance-critical applications. If you want to become a serious systems programmer, understand how memory works, or simply build a rock-solid foundation before moving to C++, Java or Python — start here.
Why MYCPLUS Trusted by C programmers since 2004 — every tutorial includes working source code you can compile, run and learn from immediately.
A beginner-first guide to arrays in C, with tested programs for test scores, temperatures, a playlist and a cinema seat map.
Build a two-way serial chat between two PCs in C, from the null-modem wiring to raw-mode ports, message framing and error detection that works.
A beginner-first guide to C pointers: arrays, functions, dynamic memory, linked lists and function pointers, with every program compiled and tested.
LRU and FIFO cache replacement in C, checked against Valgrind: a matrix walk that misses 100% of the time, and Belady’s anomaly.
A Breakout-style brick game in C and modern C++ for Windows, Linux and macOS terminals: full source, collisions, paddle aim, redraws and timing.
How for, while and do-while loops work in C, when to use each, how to leave nested loops, and the loop bugs compilers do not catch.
Unions in C explained with compiled examples: size and layout, type punning rules, tagged unions, and the C++ std::variant alternative.
The difference between malloc and calloc in C, with measured costs, realloc and free, four heap bugs caught by sanitizers, and C++ new and delete.
Setting up a TCP connection takes six system calls. Using it correctly means handling a byte stream with no message boundaries and partial transfers.
The most copied base64 implementation in C has a heap over-read in its own example. Here is a correct one, checked against the RFC 4648 test vectors.
Before it sends a byte, a ping program has to get past the kernel. Portable C for Linux and macOS, the Winsock differences, and all four permission routes.
Only one branch runs, but both decide the type — and that is where printf goes wrong. Tested C examples, plus the MAX macro trap.