<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>C on AI VOID</title><link>https://ai-blog.noorshomelab.dev/tags/c/</link><description>Recent content in C on AI VOID</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 03 Nov 2025 01:00:00 +0000</lastBuildDate><atom:link href="https://ai-blog.noorshomelab.dev/tags/c/index.xml" rel="self" type="application/rss+xml"/><item><title>C Programming Guide</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/</guid><description/></item><item><title>Chapter 3: Control Flow: Decisions and Loops</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/control-flow-decisions-loops/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/control-flow-decisions-loops/</guid><description>&lt;h1 id="chapter-3-control-flow-decisions-and-loops"&gt;Chapter 3: Control Flow: Decisions and Loops&lt;/h1&gt;
&lt;p&gt;In the previous chapter, you learned how to store and manipulate data. But what if you want your program to make choices or repeat actions? This is where &lt;strong&gt;control flow&lt;/strong&gt; comes in. Control flow statements dictate the order in which individual instructions or statements are executed.&lt;/p&gt;
&lt;p&gt;In C, the primary control flow mechanisms are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Conditional Statements:&lt;/strong&gt; For making decisions (e.g., &amp;ldquo;if this is true, do that; otherwise, do something else&amp;rdquo;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Looping Statements:&lt;/strong&gt; For repeating a block of code multiple times.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Mastering control flow is essential for writing dynamic and intelligent programs.&lt;/p&gt;</description></item><item><title>Chapter 4: Functions: Building Modular Code</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/functions-building-modular-code/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/functions-building-modular-code/</guid><description>&lt;h1 id="chapter-4-functions-building-modular-code"&gt;Chapter 4: Functions: Building Modular Code&lt;/h1&gt;
&lt;p&gt;As your programs grow larger and more complex, simply writing all your code sequentially in the &lt;code&gt;main&lt;/code&gt; function becomes unwieldy and hard to manage. This is where &lt;strong&gt;functions&lt;/strong&gt; come in. Functions are self-contained blocks of code that perform a specific task. They are the cornerstone of modular programming, allowing you to break down a large problem into smaller, more manageable sub-problems.&lt;/p&gt;
&lt;p&gt;In this chapter, you will learn:&lt;/p&gt;</description></item><item><title>Chapter 6: Arrays and Strings: Handling Collections of Data</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/arrays-and-strings-handling-collections-of-data/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/arrays-and-strings-handling-collections-of-data/</guid><description>&lt;h1 id="chapter-6-arrays-and-strings-handling-collections-of-data"&gt;Chapter 6: Arrays and Strings: Handling Collections of Data&lt;/h1&gt;
&lt;p&gt;So far, we&amp;rsquo;ve dealt with individual variables. But what if you need to store a collection of related items, like a list of student scores or a sequence of characters that form a name? This is where &lt;strong&gt;arrays&lt;/strong&gt; and &lt;strong&gt;strings&lt;/strong&gt; come in.&lt;/p&gt;
&lt;p&gt;In C, arrays are fundamental for storing multiple values of the same data type in contiguous memory locations. Strings are a special case of character arrays. This chapter will cover:&lt;/p&gt;</description></item><item><title>Chapter 7: Memory Management: `malloc`, `calloc`, `realloc`, `free`</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/memory-management/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/memory-management/</guid><description>&lt;h1 id="chapter-7-memory-management-malloc-calloc-realloc-free"&gt;Chapter 7: Memory Management: &lt;code&gt;malloc&lt;/code&gt;, &lt;code&gt;calloc&lt;/code&gt;, &lt;code&gt;realloc&lt;/code&gt;, &lt;code&gt;free&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;Up until now, all the variables we&amp;rsquo;ve used have been allocated automatically by the compiler in either &lt;strong&gt;static memory&lt;/strong&gt; (for global variables) or the &lt;strong&gt;stack&lt;/strong&gt; (for local variables and function parameters). This is sufficient for many tasks, but it has limitations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Fixed Size:&lt;/strong&gt; Stack-allocated arrays (like &lt;code&gt;int arr[10];&lt;/code&gt;) must have their size known at compile time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Limited Lifetime:&lt;/strong&gt; Stack variables are automatically destroyed when their function exits.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Dynamic Memory Allocation&lt;/strong&gt; allows your program to request memory from the operating system during runtime (when the program is executing) from an area called the &lt;strong&gt;heap&lt;/strong&gt;. This memory persists until explicitly deallocated or the program ends. This is crucial for:&lt;/p&gt;</description></item><item><title>Chapter 9: File I/O: Interacting with Files</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/file-io/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/file-io/</guid><description>&lt;h1 id="chapter-9-file-io-interacting-with-files"&gt;Chapter 9: File I/O: Interacting with Files&lt;/h1&gt;
&lt;p&gt;Most programs need to interact with the outside world, and often this means reading data from or writing data to files on a storage device (like an SSD or hard drive). This allows your programs to store persistent data, process large datasets, or communicate with other applications.&lt;/p&gt;
&lt;p&gt;In C, file input/output (I/O) is handled through a set of standard library functions declared in &lt;code&gt;&amp;lt;stdio.h&amp;gt;&lt;/code&gt;. This chapter will cover:&lt;/p&gt;</description></item><item><title>Chapter 11: Bitwise Operations: Working at the Bit Level</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/bitwise-operations/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/bitwise-operations/</guid><description>&lt;h1 id="chapter-11-bitwise-operations-working-at-the-bit-level"&gt;Chapter 11: Bitwise Operations: Working at the Bit Level&lt;/h1&gt;
&lt;p&gt;Up until now, we&amp;rsquo;ve mostly treated data as whole numbers, characters, or floating-point values. However, at the lowest level, computers store and process all information as sequences of &lt;strong&gt;bits&lt;/strong&gt; (binary digits, 0s and 1s).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Bitwise operations&lt;/strong&gt; allow you to manipulate these individual bits within integer types. This is a fundamental skill for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Low-level programming:&lt;/strong&gt; Interacting directly with hardware registers.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Embedded systems:&lt;/strong&gt; Controlling peripherals, setting flags.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data compression and encryption:&lt;/strong&gt; Efficiently packing/unpacking data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Optimized algorithms:&lt;/strong&gt; Sometimes, bitwise operations can be significantly faster than arithmetic operations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Representing sets/flags:&lt;/strong&gt; Using individual bits to represent a collection of boolean states.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this chapter, we will explore C&amp;rsquo;s bitwise operators and learn how to use them effectively.&lt;/p&gt;</description></item><item><title>Chapter 12: Intermediate Topics: Advanced Pointers and Function Pointers</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/advanced-pointers-and-function-pointers/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/advanced-pointers-and-function-pointers/</guid><description>&lt;h1 id="chapter-12-intermediate-topics-advanced-pointers-and-function-pointers"&gt;Chapter 12: Intermediate Topics: Advanced Pointers and Function Pointers&lt;/h1&gt;
&lt;p&gt;In Chapter 5, we introduced the fundamental concepts of pointers. Now, we&amp;rsquo;ll delve into more advanced aspects of pointers that are essential for handling complex data structures, dynamic memory management, and flexible program design.&lt;/p&gt;
&lt;p&gt;This chapter will cover:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Pointers to Pointers:&lt;/strong&gt; When you need to modify a pointer itself from a function.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Arrays of Pointers:&lt;/strong&gt; Storing multiple pointers in an array.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pointers to Arrays:&lt;/strong&gt; A pointer that points to an entire array.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pointers to Structures:&lt;/strong&gt; Advanced usage with dynamically allocated structs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Function Pointers:&lt;/strong&gt; Pointers that point to functions, enabling callback mechanisms and dynamic function calls.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Command-Line Arguments:&lt;/strong&gt; Understanding &lt;code&gt;argc&lt;/code&gt; and &lt;code&gt;argv&lt;/code&gt; as an array of character pointers.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="121-pointers-to-pointers-double-pointers-revisited"&gt;12.1 Pointers to Pointers (Double Pointers) Revisited&lt;/h2&gt;
&lt;p&gt;We briefly touched upon this in Chapter 5. A pointer to a pointer stores the address of another pointer. This is particularly useful when a function needs to modify a pointer variable that was passed to it from the calling function.&lt;/p&gt;</description></item><item><title>Chapter 13: Intermediate Topics: Command-Line Arguments and Environment Variables</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/command-line-arguments-environment-variables/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/command-line-arguments-environment-variables/</guid><description>&lt;h1 id="chapter-13-intermediate-topics-command-line-arguments-and-environment-variables"&gt;Chapter 13: Intermediate Topics: Command-Line Arguments and Environment Variables&lt;/h1&gt;
&lt;p&gt;C programs are often run in terminal or shell environments, making direct interaction with the execution context crucial. This interaction primarily happens through &lt;strong&gt;command-line arguments&lt;/strong&gt; and &lt;strong&gt;environment variables&lt;/strong&gt;. Understanding these mechanisms allows you to write flexible programs that can be configured at runtime and integrate seamlessly into larger system scripts or workflows.&lt;/p&gt;
&lt;p&gt;In this chapter, we will deepen our understanding of:&lt;/p&gt;</description></item><item><title>Chapter 14: Advanced Topics: Memory Alignment and Optimization</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/memory-alignment-and-optimization/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/memory-alignment-and-optimization/</guid><description>&lt;h1 id="chapter-14-advanced-topics-memory-alignment-and-optimization"&gt;Chapter 14: Advanced Topics: Memory Alignment and Optimization&lt;/h1&gt;
&lt;p&gt;In low-level C programming, understanding how data is laid out in memory and how the CPU interacts with it is crucial for writing efficient and high-performance code. This chapter delves into advanced memory concepts, specifically &lt;strong&gt;memory alignment&lt;/strong&gt; and &lt;strong&gt;structure padding&lt;/strong&gt;, and then explores various &lt;strong&gt;optimization techniques&lt;/strong&gt; that C programmers can employ.&lt;/p&gt;
&lt;p&gt;While modern compilers are highly intelligent and perform many optimizations automatically, explicit understanding of these concepts empowers you to write code that gives the compiler the best chance to optimize, or to hand-tune critical sections for maximum performance.&lt;/p&gt;</description></item><item><title>Chapter 15: Advanced Topics: Linking C with Assembly Language</title><link>https://ai-blog.noorshomelab.dev/c-programming-guide/linking-c-with-assembly/</link><pubDate>Mon, 03 Nov 2025 01:00:00 +0000</pubDate><guid>https://ai-blog.noorshomelab.dev/c-programming-guide/linking-c-with-assembly/</guid><description>&lt;h1 id="chapter-15-advanced-topics-linking-c-with-assembly-language"&gt;Chapter 15: Advanced Topics: Linking C with Assembly Language&lt;/h1&gt;
&lt;p&gt;At the heart of low-level programming lies the ability to interact directly with the hardware and exploit the full potential of the CPU. While C provides excellent control, there are times when even C isn&amp;rsquo;t &amp;ldquo;low-level enough.&amp;rdquo; This is where &lt;strong&gt;Assembly Language&lt;/strong&gt; comes in.&lt;/p&gt;
&lt;p&gt;Assembly language is a human-readable representation of the machine code instructions that a processor executes. Linking C with Assembly allows you to:&lt;/p&gt;</description></item></channel></rss>