<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rauf Ahmadzada on Medium]]></title>
        <description><![CDATA[Stories by Rauf Ahmadzada on Medium]]></description>
        <link>https://medium.com/@raufahmedzade020?source=rss-ee78763c445b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MCzb_maufsIQJ3LSDbTkog.jpeg</url>
            <title>Stories by Rauf Ahmadzada on Medium</title>
            <link>https://medium.com/@raufahmedzade020?source=rss-ee78763c445b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 07:00:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raufahmedzade020/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What happens when you type gcc main.c ?]]></title>
            <link>https://medium.com/@raufahmedzade020/what-happens-when-you-type-gcc-main-c-0939161d5b9e?source=rss-ee78763c445b------2</link>
            <guid isPermaLink="false">https://medium.com/p/0939161d5b9e</guid>
            <category><![CDATA[preprocesing]]></category>
            <category><![CDATA[linking]]></category>
            <category><![CDATA[assembling]]></category>
            <category><![CDATA[compiling]]></category>
            <category><![CDATA[c-programming]]></category>
            <dc:creator><![CDATA[Rauf Ahmadzada]]></dc:creator>
            <pubDate>Fri, 23 Feb 2024 08:17:33 GMT</pubDate>
            <atom:updated>2024-02-23T08:17:33.535Z</atom:updated>
            <content:encoded><![CDATA[<h3>What happens when you type gcc main.c ?</h3><p>Understanding the gcc command: Compilation Steps</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rZAuhSTZbgqv4qC1hQO31Q.jpeg" /></figure><h3><strong>Introduction</strong></h3><p>If you are a C programmer, you probably use the gcc command to compile your source code into executable files.</p><p>But do you know what gcc actually does behind the scenes?</p><p>How does it transform your human-readable code into machine-readable instructions?</p><p>In this blog post, we will explore the steps of compilation and see how gcc works its magic.</p><h3>The steps of compilation</h3><p>The compilation process can be divided into four main steps: preprocessing, compiling, assembling, and linking. Each step has a specific role and produces an intermediate output file.</p><p>Let’s see what each step does and how to invoke it using gcc.</p><h3>Preprocessing</h3><p>The first step is preprocessing. This is where the preprocessor directives, such as <strong>#include</strong> and <strong>#define</strong>, are processed and expanded. The preprocessor also removes comments and white spaces from the source code. The result is a single file that contains the complete source code with all the necessary headers and macros. This file is called the preprocessed source file and has the extension <strong>.i</strong>.</p><p>To perform only the preprocessing step, you can use the <strong>-E</strong> option with gcc. For example, if you have a file called <strong>hello_world.c</strong> that contains the following code:</p><pre>#include &lt;stdio.h&gt;<br><br>#define NAME &quot;Holberton&quot;<br><br>int main(void) {<br>    printf(&quot;Hello, %s!\n&quot;, NAME);<br>    return 0;<br>}</pre><p>You can run the following command to generate the preprocessed source file <strong>hello_world.i</strong>:</p><pre>gcc -E hello_world.c -o hello_world.i</pre><p>If you open the<strong> </strong><strong>hello_world.i</strong> file, you will see something like this:</p><pre># 1 &quot;hello_world.c&quot;<br># 1 &quot;&lt;built-in&gt;&quot;<br># 1 &quot;&lt;command-line&gt;&quot;<br># 1 &quot;hello_world.c&quot;<br># 1 &quot;/usr/include/stdio.h&quot; 1 3 4<br># 27 &quot;/usr/include/stdio.h&quot; 3 4<br># 1 &quot;/usr/include/features.h&quot; 1 3 4<br># 424 &quot;/usr/include/features.h&quot; 3 4<br># 1 &quot;/usr/include/sys/cdefs.h&quot; 1 3 4<br># 427 &quot;/usr/include/sys/cdefs.h&quot; 3 4<br># 1 &quot;/usr/include/bits/wordsize.h&quot; 1 3 4<br># 428 &quot;/usr/include/sys/cdefs.h&quot; 2 3 4<br># 1 &quot;/usr/include/bits/long-double.h&quot; 1 3 4<br># 429 &quot;/usr/include/sys/cdefs.h&quot; 2 3 4<br># 425 &quot;/usr/include/features.h&quot; 2 3 4<br># 448 &quot;/usr/include/features.h&quot; 3 4<br># 1 &quot;/usr/include/gnu/stubs.h&quot; 1 3 4<br># 10 &quot;/usr/include/gnu/stubs.h&quot; 3 4<br># 1 &quot;/usr/include/gnu/stubs-64.h&quot; 1 3 4<br># 11 &quot;/usr/include/gnu/stubs.h&quot; 2 3 4<br># 449 &quot;/usr/include/features.h&quot; 2 3 4<br># 28 &quot;/usr/include/stdio.h&quot; 2 3 4<br><br>...<br><br># 2 &quot;hello_world.c&quot; 2<br><br># 4 &quot;hello_world.c&quot;<br><br>int main(void) {<br>    printf(&quot;Hello, %s!\n&quot;, &quot;Holberton&quot;);<br>    return 0;<br>}</pre><p>As you can see, the preprocessor has included the contents of the <strong>stdio.h</strong> header file and replaced the <strong>NAME</strong> macro with its value. It has also added some lines that start with <strong>#</strong> to indicate the origin of each line of code.</p><h3>Compiling</h3><p>The next step is compiling. This is where the preprocessed source file is converted into assembly code, which is a low-level representation of the instructions that the processor can execute. The assembly code is specific to the target architecture and operating system. The output file of this step is called the assembly file and has the extension <strong>.s</strong>.</p><p>To perform only the compiling step, you can use the <strong>-S</strong> option with gcc. For example, if you have the preprocessed source file <strong>hello_world.i</strong>, you can run the following command to generate the assembly file <strong>hello_world.s</strong>:</p><pre>gcc -S hello_world.i -o hello_world.s</pre><p>If you open the <strong>hello_world.s</strong> file, you will see something like this:</p><pre>.file	&quot;hello_world.c&quot;<br>	.section	.rodata<br>.LC0:<br>	.string	&quot;Hello, %s!\n&quot;<br>	.text<br>	.globl	main<br>	.type	main, @function<br>main:<br>.LFB0:<br>	.cfi_startproc<br>	pushq	%rbp<br>	.cfi_def_cfa_offset 16<br>	.cfi_offset 6, -16<br>	movq	%rsp, %rbp<br>	.cfi_def_cfa_register 6<br>	subq	$16, %rsp<br>	movl	$0, -4(%rbp)<br>	movl	$.LC0, %edi<br>	movl	$0, %eax<br>	call	printf<br>	movl	$0, %eax<br>	leave<br>	.cfi_def_cfa 7, 8<br>	ret<br>	.cfi_endproc<br>.LFE0:<br>	.size	main, .-main<br>	.ident	&quot;GCC: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0&quot;<br>	.section	.note.GNU-stack,&quot;&quot;,@progbits</pre><p>As you can see, the assembly code is much more cryptic and verbose than the C code. It uses mnemonics, such as <strong>pushq</strong>, <strong>movq</strong>, and <strong>call</strong>, to represent the operations that the processor can perform. It also uses labels, such as <strong>.LC0</strong> and <strong>.LFB0</strong>, to mark the locations of data and functions. It also uses directives, such as <strong>.file</strong>, <strong>.section</strong>, and <strong>.globl</strong>, to provide additional information to the assembler.</p><h3>Assembling</h3><p>The third step is assembling. This is where the assembly code is translated into binary code, which is the actual sequence of bits that the processor can understand and execute. The binary code is stored in an object file, which contains the machine code and some metadata, such as symbols, relocation entries, and debug information. The object file has the extension <strong>.o</strong>.</p><p>To perform only the assembling step, you can use the <strong>-c</strong> option with gcc. For example, if you have the assembly file <strong>hello_world.s</strong>, you can run the following command to generate the object file <strong>hello_world.o</strong>:</p><pre>gcc -c hello_world.s -o hello_world.o</pre><p>If you open the <strong>hello_world.o</strong> file with a hex editor, you will see something like this:</p><pre>7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00<br>02 00 3e 00 01 00 00 00 40 05 00 00 00 00 00 00<br>40 00 00 00 00 00 00 00 28 02 00 00 00 00 00 00<br>00 00 00 00 40 00 38 00 09 00 40 00 1e 00 1b 00<br>06 00 00 00 05 00 00 00 40 00 00 00 00 00 00 00<br>40 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00<br>f8 01 00 00 00 00 00 00 f8 01 00 00 00 00 00 00<br>08 00 00 00 00 00 00 00 03 00 00 00 04 00 00 00<br>38 02 00 00 00 00 00 00 38 02 00 00 00 00 00 00<br>38 02 00 00 00 00 00 00 1c 00 00 00 00 00 00 00<br>1c 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00<br>01 00 00 00 05 00 00 00 00 00 00 00 00 00 00 00<br>00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00<br>20 00 00 00 00 00 00 00 20 00 00 00 00 00 00 00<br>00 00 00 00 00 00 00 00 11 00 00 00 00 00 00 00<br>11 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00<br>11 00 00 00 06</pre><h3>Linking</h3><p>The final step is linking. This is where the object files are combined with the libraries and other dependencies to produce the final executable file, which can be run by the operating system. The linker resolves the references to external symbols, such as functions and variables, that are defined in other object files or libraries. The linker also performs relocation, which is the process of adjusting the addresses of the symbols according to their final location in memory. The output file of this step is called the executable file and has the extension <strong>.out</strong> by default.</p><p>To perform the linking step, you can use gcc without any option. For example, if you have the object file <strong>hello_world.o</strong>, you can run the following command to generate the executable file <strong>a.out</strong>:</p><pre>gcc hello_world.o -o a.out</pre><p>If you run the executable file, you will see the output of your program:</p><pre>./a.out<br>Hello, Holberton!</pre><p>You can also specify a different name for the executable file using the -o option. For example, you can run the following command to generate the executable file <strong>hello_world</strong>:</p><pre>gcc hello_world.o -o hello_world</pre><h3>The shortcut</h3><p>As you can see, the compilation process involves four steps and four intermediate files. However, you don’t have to perform each step separately and manually. You can use gcc to perform all the steps at once, by passing the source file as the input and the executable file as the output. For example, you can run the following command to compile and link your <strong>hello_world.c</strong> file in one go:</p><pre>gcc hello_world.c -o hello_world</pre><p>This command will produce the same executable file as the previous commands, but without creating any intermediate files. This is the most common and convenient way to use gcc, as it saves you time and disk space.</p><h3>Conclusion</h3><p>In this blog post, we have learned what happens when you type gcc main.c. We have seen the four steps of compilation: preprocessing, compiling, assembling, and linking. We have also seen how to perform each step using gcc and how to use gcc to perform all the steps at once. We have learned that gcc is a powerful and versatile tool that can transform your source code into executable files.</p><p>I hope you have enjoyed this blog post and learned something new. If you have any questions or feedback, please leave a comment below.</p><p>Thank you for reading and happy coding! 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0939161d5b9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What happens when you type ls *.c and hit Enter in your Shell?]]></title>
            <link>https://medium.com/@raufahmedzade020/what-happens-when-you-type-ls-c-and-hit-enter-in-your-shell-f70a4e85148d?source=rss-ee78763c445b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f70a4e85148d</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[shell-script]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[shell]]></category>
            <dc:creator><![CDATA[Rauf Ahmadzada]]></dc:creator>
            <pubDate>Sun, 18 Feb 2024 15:09:21 GMT</pubDate>
            <atom:updated>2024-02-18T15:09:21.359Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Understanding the </strong><strong>ls *.c Command: A Beginner’s Guide</strong></h4><figure><img alt="Robo Cowboy coding in Shell" src="https://cdn-images-1.medium.com/max/1024/1*g8yz_NzZGxYbPU2D_DMMUg.jpeg" /></figure><h3>Introduction</h3><p>When you’re navigating through your computer’s files and directories, the <strong>ls</strong> command becomes your trusty guide. Today, we’ll explore a specific variation of this command: <strong>ls *.c</strong>. Buckle up, because we’re demystifying what happens when you type this seemingly cryptic sequence and hit Enter.</p><h3>Step 1: The Basics</h3><h3>What Is ls?</h3><p>The <strong>ls</strong> command stands for “list.” Its primary job is to display files and directories in the current working directory. Think of it as your digital flashlight, illuminating the contents of your folder.</p><h3>The Mysterious *.c</h3><p>Now, let’s dissect the intriguing part: <strong>*.c</strong>. This is a wildcard. Imagine it as a magic wand that says, “Show me all files with a <strong>.c</strong> extension.” It’s like asking your computer, “Hey, can you find all those sneaky <strong>.c</strong> files for me?”</p><h3>Step 2: The Search Begins</h3><p>Let’s say you’re in a directory with these files:</p><ul><li><strong>file1.txt</strong></li><li><strong>file2.c</strong></li><li><strong>file3.c</strong></li></ul><h3>Running ls</h3><p>When you type <strong>ls</strong> and hit Enter, your shell obediently lists all files and directories. In our case, it would display:</p><pre>file1.txt  file2.c  file3.c</pre><h3>Step 3: The Wildcard Unleashed</h3><p>Now, let’s add the magical <strong>*.c</strong>:</p><h4><strong>ls *.c</strong></h4><p>The shell springs into action. It scans the directory for files ending with .c and presents them to you. Our output becomes:</p><pre>file2.c  file3.c</pre><h3>Step 4: The Wizardry Explained</h3><h3>How Does the Wildcard Work?</h3><ul><li>The <strong>*</strong> represents any characters (or none at all).</li><li>So, <strong>*.c</strong> matches all files with any name ending in <strong>.c</strong>.</li><li>If you had more files like <strong>mycode.c</strong>, <strong>project.c</strong>, and <strong>notes.c</strong>, they’d all be listed.</li></ul><h3>Step 5: More Examples</h3><p>Let’s play with other scenarios:</p><ul><li>Suppose you have these files:</li></ul><pre>report.doc <br>notes.txt <br>code.c <br>data.csv</pre><ul><li>Running <strong>ls *.c</strong> would show only <strong>code.c</strong>.</li><li>Running <strong>ls *.*</strong> would list all files with any extension.</li></ul><h3>Step 6: Decoding the Output</h3><p>The output might look cryptic at first, but it’s packed with information:</p><pre>-rw-r--r-- 1 user group 1234 Feb 18 10:30 code.c</pre><ul><li><strong>-rw-r--r--</strong>: File permissions (readable, writable for user, readable for group and others).</li><li><strong>1</strong>: Number of hard links to the file.</li><li><strong>user</strong>: File owner.</li><li><strong>group</strong>: File group.</li><li><strong>1234</strong>: File size in bytes.</li><li><strong>Feb 18 10:30</strong>: Modification date.</li><li><strong>code.c</strong>: File name.</li></ul><h3>Conclusion</h3><p>You’ve just deciphered the magic behind <strong>ls *.c</strong>. Next time you encounter this command, remember that it’s your ticket to exploring specific file types. Happy navigating! 🚀🔍</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f70a4e85148d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>