<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Haile Melaku</title>
    <description>The latest articles on DEV Community by Haile Melaku (@haile08).</description>
    <link>https://dev.to/haile08</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F611774%2Fc1fe1c7c-973b-4371-9cbc-8559df46841b.png</url>
      <title>DEV Community: Haile Melaku</title>
      <link>https://dev.to/haile08</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/haile08"/>
    <language>en</language>
    <item>
      <title>MeritGifts</title>
      <dc:creator>Haile Melaku</dc:creator>
      <pubDate>Thu, 21 Dec 2023 19:40:59 +0000</pubDate>
      <link>https://dev.to/haile08/meritgifts-2h7i</link>
      <guid>https://dev.to/haile08/meritgifts-2h7i</guid>
      <description>&lt;p&gt;&lt;a href="https://github.com/Haile-08/MeritaGifts"&gt;https://github.com/Haile-08/MeritaGifts&lt;/a&gt;&lt;/p&gt;

</description>
      <category>argc</category>
      <category>argv</category>
      <category>c</category>
      <category>beginners</category>
    </item>
    <item>
      <title>C - argc, argv</title>
      <dc:creator>Haile Melaku</dc:creator>
      <pubDate>Mon, 10 Oct 2022 13:58:06 +0000</pubDate>
      <link>https://dev.to/haile08/c-argc-argv-2cf1</link>
      <guid>https://dev.to/haile08/c-argc-argv-2cf1</guid>
      <description>&lt;p&gt;Arguments on main are used to guide on how the program does it's job, when the programs are run in a hosted environment. &lt;br&gt;
They are also used to pass the name of the file to the program.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A host environment&lt;/strong&gt; is any OS environment that satisfy the basic requirement to be called an Operating system(os) like RAM, CPU, etc ..&lt;/p&gt;

&lt;p&gt;Declaration of arguments on main is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int main(int argc, char *argv[]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit status is used to indicate that a program completed successfully (a zero value)(exit(0);) or some error occurred (a non-zero value).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;argc&lt;/code&gt; : is the number of the arguments supplied to the program.&lt;br&gt;
&lt;code&gt;arv[]&lt;/code&gt; : is the array pointer of arguments given to the program.&lt;/p&gt;

&lt;p&gt;In arv[] the last value of the array or arv[argc] is null('\0').&lt;/p&gt;


&lt;h2&gt;
  
  
  #argc and argv
&lt;/h2&gt;

&lt;p&gt;Up until now we have seen that argc is the number of argument and arv[] is array pointer of all the argument that are written on the terminal.&lt;/p&gt;

&lt;p&gt;A really good example of argc and argv is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcc main.c -o main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case the values &lt;code&gt;gcc&lt;/code&gt;, &lt;code&gt;main.c&lt;/code&gt;, &lt;code&gt;-o&lt;/code&gt;  and &lt;code&gt;main&lt;/code&gt; are arguments that are passed to the gcc program using argv[].&lt;br&gt;
the value of the arguments will be like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;argc = 4
argv[0] = gcc
argv[1] = main.c
argv[2] = -o
argv[3] = main
argv[4] = null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HRtmuUHR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xklmxuv5sjr7r8ykomdj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HRtmuUHR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xklmxuv5sjr7r8ykomdj.png" alt="Image description" width="683" height="473"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Output&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_hQChmGg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crvzmzyp2s5c8xidih2h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_hQChmGg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crvzmzyp2s5c8xidih2h.png" alt="Image description" width="669" height="156"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we ever want to make an operation on the values of the parameter argv[] use the function &lt;code&gt;atoi()&lt;/code&gt; to convert the string to an integer also don't forget to include the library &lt;code&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sabWGRxi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45wubvtnp94jppmm30e6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sabWGRxi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45wubvtnp94jppmm30e6.png" alt="Image description" width="767" height="361"&gt;&lt;/a&gt;&lt;br&gt;
output&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--udx2haly--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/khyiu7da3095j4e7tury.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--udx2haly--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/khyiu7da3095j4e7tury.png" alt="Image description" width="567" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: to skip unused variable type cast the variable to &lt;code&gt;void&lt;/code&gt; like &lt;code&gt;(void)UNUSED_VAR;&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Example&lt;br&gt;
If a variable in the parameter like argc, argv[] or any other variable, let's say you didn't use argc variable in the code you can skip the error of unused variable like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(void)argc;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>argc</category>
      <category>argv</category>
      <category>c</category>
    </item>
    <item>
      <title>C - Static libraries</title>
      <dc:creator>Haile Melaku</dc:creator>
      <pubDate>Sun, 09 Oct 2022 14:07:59 +0000</pubDate>
      <link>https://dev.to/haile08/c-static-libraries-iki</link>
      <guid>https://dev.to/haile08/c-static-libraries-iki</guid>
      <description>&lt;p&gt;Up until now we wore working with smaller program's,but when we create a very large program we are faced with some problem like&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Increase in overall time of compilation and linking.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;polluting out makefile.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;polluting out directory where we placed the source files.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;when we are faced with this problem's, we might look of a way of combining the source code into small units of related files.&lt;/p&gt;




&lt;h2&gt;
  
  
  #What Is A "C" Library
&lt;/h2&gt;

&lt;p&gt;A library is a file containing several object files,used in the linking Phase of a program.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why use Library's&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Library is indexed so that it is easy to find functions, variables and others&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Linking a program whose object files are ordered in libraries is faster than linking a program whose object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Speeds up linking&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can create two types of library's&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;static libraries&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;shared (or dynamic) libraries&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;static libraries&lt;/strong&gt;&lt;br&gt;
Are object files that are linked into the program during the linking phase of compilation and are not used during the runtime.&lt;/p&gt;

&lt;p&gt;During the creation of the executable file static library's are copied in the source code,so we can run the program only with the executable file.&lt;/p&gt;

&lt;p&gt;The drawback of static linking is the size of the file will increase, maintaining update of the app is hard as the create file has everything it needs to run on it's own and we need to recompile every time we use the program.&lt;/p&gt;

&lt;p&gt;Static library in &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Windows have a &lt;code&gt;.lib&lt;/code&gt; (library) extension &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Linux have a &lt;code&gt;.a&lt;/code&gt; (Archive) extension&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Shared libraries (dynamic libraries)&lt;/strong&gt;&lt;br&gt;
Are object files that are linked into the program both during the linking phase of compilation and during the runtime.&lt;/p&gt;

&lt;p&gt;During the compile time of the program the shared libraries are used to verifies that all the functions, variables and others required by the program, are either linked into the program, or in one of its shared libraries.&lt;/p&gt;

&lt;p&gt;During the runtime of the program the shared libraries are loaded to memory by the program.&lt;/p&gt;

&lt;p&gt;When we create the executable of a file the address of the shared library are stored in the final executable file.&lt;/p&gt;

&lt;p&gt;Some drawback of dynamic linking is launching the program is slightly slower and when we recompile the program we face a  problem which is the copy of the previous library is already stored in memory.&lt;/p&gt;

&lt;p&gt;Dynamic library solves some of the problem's with static inking such as size and need for compilation.&lt;/p&gt;

&lt;p&gt;Shard library in &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Windows have a &lt;code&gt;.dll&lt;/code&gt; (dynamic link library) extension &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Linux have a &lt;code&gt;.so&lt;/code&gt; (shard object) extension&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  #Creating A Static "C" Library
&lt;/h2&gt;

&lt;p&gt;We can create a static library using a program called 'ar', for 'archiver'.&lt;br&gt;
To create a static library use the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ar rc static_lib.a factorial.o mult.o 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates a static library named static_lib.a using two Object file's factorial.o and mult.o,&lt;code&gt;r&lt;/code&gt; tells the archiver to replace older object files in the library, with the new object files and &lt;code&gt;c&lt;/code&gt; tells the archiver to create the library if it doesn't already exist.&lt;/p&gt;

&lt;p&gt;To create an object file form a c file use the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcc -g -O -c factorial.c
gcc -g -O -c mult.c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have created the static library we need to index it.&lt;br&gt;
Index is used to by the compiler to speed up symbol-lookup (like functions, variable and so on) inside the library.&lt;/p&gt;

&lt;p&gt;The command used to create or update the index is called 'ranlib' and is used like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ranlib static_lib.a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;For more info use the commands &lt;code&gt;man ar&lt;/code&gt; and &lt;code&gt;man ranlib&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  #Using A "C" Library In A Program
&lt;/h2&gt;

&lt;p&gt;Up to now we learned about creating a static library and now we want to use this library in our program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcc main.c static_lib.a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example we will compile the main.c program while requiring the static_lib.a library.&lt;/p&gt;




&lt;h2&gt;
  
  
  #Creating A Shared "C" Library
&lt;/h2&gt;

&lt;p&gt;shared(Dynamic) library has the same process of creation as static library, but it differs in two ways&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When creating the object file for the library we have to use the flags &lt;code&gt;-fPIC&lt;/code&gt; or &lt;code&gt;-fpic&lt;/code&gt; which are "Position Independent Code"(PIC) to use relative address of the memory, because many different programs may load the program into different location of the memory.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcc -fPIC -c factorial.c
gcc -fPIC -c mult.c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Unlike static library a shared library is not an archive file,So it has to be specifically tailored to the operating system it is being created.
we could use the &lt;code&gt;-G&lt;/code&gt; flag or &lt;code&gt;-shared&lt;/code&gt; flag depending on the compiler.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcc -shared shared_lib.so factorial.o mult.o
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example we use the flag &lt;code&gt;-shared&lt;/code&gt; to create the shared library for this library named &lt;code&gt;shared_lib.so&lt;/code&gt; using the object files factorial.o and mult.o,By looking at the extension &lt;code&gt;.os&lt;/code&gt; we can conclude that this library run on linux.&lt;/p&gt;




&lt;h2&gt;
  
  
  #Using A Shared "C" Library
&lt;/h2&gt;

&lt;p&gt;As we have mentioned we use the shared library in two cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compile Time - tells the linker to scan the shared library while building the executable program.
It's done the same as static library
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gcc main.c shared_lib.os
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Run Time - tells the loader where to find our shared library.
Using the shared library is a little trickier when used in run time.
we can use the 'LD_LIBRARY_PATH' environment variable to tell the loader to look in other directories.
In &lt;code&gt;bash&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LD_LIBRARY_PATH=/full/path/to/library/directory
export LD_LIBRARY_PATH
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  #Loading A Shared Library Using dlopen()
&lt;/h2&gt;

&lt;p&gt;To load and open a shared(dynamic) library we use the dlopen() function.&lt;/p&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;dlfcn.h&amp;gt;      /* defines dlopen(), etc.       */

int main(void)
{
void* lib_handle;       /* handle of the opened library */

lib_handle = dlopen("/full/path/to/library", RTLD_LAZY);
if (!lib_handle) {
    fprintf(stderr, "Error during dlopen(): %s\n", dlerror());
    exit(1);
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;dlopen() takes two parameters,first one is the full path to shared library and the second one is used to check if the symbols of the library need to be checked immediately(RTLD_LOCAL), or only when used(RTLD_LAZY).&lt;/p&gt;

</description>
      <category>c</category>
      <category>libraries</category>
      <category>static</category>
      <category>beginners</category>
    </item>
    <item>
      <title>C - Recursion</title>
      <dc:creator>Haile Melaku</dc:creator>
      <pubDate>Sun, 09 Oct 2022 09:51:42 +0000</pubDate>
      <link>https://dev.to/haile08/c-recursion-13nk</link>
      <guid>https://dev.to/haile08/c-recursion-13nk</guid>
      <description>

&lt;h2&gt;
  
  
  #C - Recursion
&lt;/h2&gt;

&lt;p&gt;Recursion is a method of calling a function inside a function iteratively.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void recursion() {
   recursion(); /* function calls itself */
}

int main() {
   recursion();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case the function recursion calls  a copy of itself to work on a smaller problem until some conditional is satisfied.&lt;/p&gt;

&lt;p&gt;Any function which calls itself is called recursive function, and such function calls are called recursive calls.&lt;/p&gt;

&lt;p&gt;Recursion is a method of solving problems based on the divide and conquer mentality and we break the problem into much smaller sub part's of itself, one of the subpart consists the a conditional to break the recursion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Creating a recursive function to find the factorial of a number&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mYweSHlg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/auquykamv9rjilv41ebk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mYweSHlg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/auquykamv9rjilv41ebk.png" alt="Image description" width="587" height="580"&gt;&lt;/a&gt;&lt;br&gt;
Output&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1dXk_7do--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cx4j86p53dcdiacp8y7c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1dXk_7do--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cx4j86p53dcdiacp8y7c.png" alt="Image description" width="538" height="69"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>recursion</category>
      <category>c</category>
    </item>
    <item>
      <title>C - Even more pointers, arrays and strings</title>
      <dc:creator>Haile Melaku</dc:creator>
      <pubDate>Sat, 08 Oct 2022 17:12:31 +0000</pubDate>
      <link>https://dev.to/haile08/c-even-more-pointers-arrays-and-strings-4nf9</link>
      <guid>https://dev.to/haile08/c-even-more-pointers-arrays-and-strings-4nf9</guid>
      <description>&lt;p&gt;Wait we haven't finished pointers yet, if you haven't seen the previous blog post i highly suggest you check it out.&lt;br&gt;
So on this blog post we are going to dive deep into even more pointers.&lt;/p&gt;


&lt;h2&gt;
  
  
  #C – Pointer to Pointer
&lt;/h2&gt;

&lt;p&gt;Pointer to pointer is a form of chained pointer in which a pointer holds the address of another pointer.&lt;/p&gt;

&lt;p&gt;The declaration of pointer to pointer is done by adding an additional asterisk in front of its name.&lt;/p&gt;

&lt;p&gt;A pointer with an &lt;code&gt;n&lt;/code&gt; amount of asterisk(&lt;em&gt;) can hold the address of any pointer with a &lt;code&gt;n - 1&lt;/code&gt; asterisks(&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;TYPE **VAR_NAME;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In this case the pointer with a double asterisk(&lt;em&gt;) can hold the address of a pointer with a single asterisk(&lt;/em&gt;) and they have the same value across.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--b_OGeE6P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12ie3hsgajqzh70xnjyh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b_OGeE6P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12ie3hsgajqzh70xnjyh.png" alt="Image description" width="867" height="752"&gt;&lt;/a&gt;&lt;br&gt;
&lt;code&gt;Output&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9JA4Pq-E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cl4n5vojiyggo36g3339.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9JA4Pq-E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cl4n5vojiyggo36g3339.png" alt="Image description" width="776" height="275"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To Generalize this Example:&lt;br&gt;
&lt;code&gt;num == *ptr1 == **ptr2&lt;/code&gt;&lt;br&gt;
&lt;code&gt;&amp;amp;num == ptr1 == *ptr2&lt;/code&gt;&lt;br&gt;
&lt;code&gt;&amp;amp;ptr1 == ptr2&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;When declaration of variable the memory layout for this example is:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uAvHbGwS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1tvjz9i6uudfdxydu90i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uAvHbGwS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1tvjz9i6uudfdxydu90i.png" alt="Image description" width="880" height="56"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7lkabGiI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/scfjr6mxbhvw74grgp57.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7lkabGiI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/scfjr6mxbhvw74grgp57.png" alt="Image description" width="880" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1GX1G46A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8wpgeblnwkn499bw4wr9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1GX1G46A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8wpgeblnwkn499bw4wr9.png" alt="Image description" width="880" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After assigning the value 10 to num the memory layout will look like&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z75S2b9Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tig1z2i2b6507gb014gq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z75S2b9Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tig1z2i2b6507gb014gq.png" alt="Image description" width="880" height="56"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T9IapwEB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hyw6bww4e2tmx95ki3fc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T9IapwEB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hyw6bww4e2tmx95ki3fc.png" alt="Image description" width="880" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--87BnM0AK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eyemijjima5kco0a99ic.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--87BnM0AK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eyemijjima5kco0a99ic.png" alt="Image description" width="880" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After adding in the address of the num to ptr1 and ptr1 to ptr2 the memory layout will look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R2BJDS13--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pofzz5ut3uvw7h9nwiu3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R2BJDS13--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pofzz5ut3uvw7h9nwiu3.png" alt="Image description" width="880" height="56"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uizAoSzf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p0g9u5jmxvyhtrhzcix0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uizAoSzf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p0g9u5jmxvyhtrhzcix0.png" alt="Image description" width="880" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KGmY2_Q7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ngafzbr8ruxwn9fo2jpg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KGmY2_Q7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ngafzbr8ruxwn9fo2jpg.png" alt="Image description" width="880" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the above tables we used numbers to represent the address of variables to better understand the concept, address are most commonly put in the like the output of the example in some form of hexadecimal.&lt;/p&gt;

&lt;p&gt;In the table the value of num = 10  and address = 13, the ptr1 holds the address of num as a value which is 13 and the address of ptr1 is 17.&lt;/p&gt;

&lt;p&gt;Now we come to pointer to pointer in the table ptr2 holds the address of the other pointer ptr1 as a value and this is the case of ptr2(double pointer) it holds the address of other pointer in it.&lt;/p&gt;


&lt;h2&gt;
  
  
  #Two dimensional (2D) arrays
&lt;/h2&gt;

&lt;p&gt;A two dimensional arrays is also know as array of arrays.&lt;/p&gt;

&lt;p&gt;To declare a two dimensional array&lt;/p&gt;

&lt;p&gt;&lt;code&gt;TYPE ARRAY_NAME[x][Y]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Where type can be any valid C data type, arrayName will be a valid C identifier, x number of rows and y number of columns.&lt;/p&gt;

&lt;p&gt;To initializing two-dimensional arrays we use two method&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int a[3][4] = {{0, 1, 2, 3},{6, 3, 61, 7},{10, 75, 1, 16}};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int a[3][4] = {0,1,2,3,6,3,61,7,10,75,1,16};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with 2D array, you must always specify the second dimension even if you are specifying elements during the declaration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int a[][] = {1, 2, 3 ,4 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is invalid because the second value is not specified.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ykII1K6F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t93m4noiqw0l2ncc2bo7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ykII1K6F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t93m4noiqw0l2ncc2bo7.png" alt="Image description" width="666" height="505"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Output&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x9duvJre--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/77zr0el14bw2u7f7qmdc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x9duvJre--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/77zr0el14bw2u7f7qmdc.png" alt="Image description" width="607" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The memory layout to the following example is &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pkJ0VbD1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0bytcco4dyrcd5974nnc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pkJ0VbD1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0bytcco4dyrcd5974nnc.png" alt="Image description" width="880" height="39"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uxniwEjW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yng3c3ijz0o8lyazbnbi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uxniwEjW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yng3c3ijz0o8lyazbnbi.png" alt="Image description" width="880" height="39"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>pointers</category>
      <category>array</category>
      <category>string</category>
      <category>c</category>
    </item>
    <item>
      <title>C - Pointers, arrays and strings</title>
      <dc:creator>Haile Melaku</dc:creator>
      <pubDate>Tue, 04 Oct 2022 10:03:01 +0000</pubDate>
      <link>https://dev.to/haile08/c-pointers-arrays-and-strings-1o13</link>
      <guid>https://dev.to/haile08/c-pointers-arrays-and-strings-1o13</guid>
      <description>&lt;p&gt;Pointer is one of the most confusing concept in c and c++, In this blog post we are going to make it easy to understand this concept.&lt;/p&gt;




&lt;h2&gt;
  
  
  #Types and memory
&lt;/h2&gt;

&lt;p&gt;When we declare a vaialbe or store any data temporarily the computer will reserve memory for this variable or data and it will store that variable or data in the reserved space in byte.&lt;/p&gt;

&lt;p&gt;The example of the memory structure representation we are going to use to understand pointers is &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzy7s0prir42vwsg7no3u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzy7s0prir42vwsg7no3u.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where the address is just put in numbers to make it easy to understand, normally it is put in hexadecimal, variable is the name and the value is the assigned ascii number attached to the variable.&lt;/p&gt;

&lt;p&gt;Depending on the type of a variable the computer will reserve a vary amount of space in memory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;1 byte = 8 bits, each bit being 0 or 1&lt;/code&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;char = 256 different value = 2^8 = 8 bits = 1 byte&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;int = 4294967296 different &lt;code&gt;value = 2^32 = 32 bits = 4 byte&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;float = 4294967296 different value = 2^32 = 32 bits = 4 byte&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can check the size of a variable type using &lt;code&gt;sizeof&lt;/code&gt; operator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When we declare a variable &lt;code&gt;l&lt;/code&gt; of type &lt;code&gt;char&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;char l;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm1hjcke09beh8lgtcbby.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm1hjcke09beh8lgtcbby.png" alt="Image description"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Int this example we created the address of l is 6.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;char l;

l = 'A';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcj0042ry0f1eq5ca74q9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcj0042ry0f1eq5ca74q9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We assigned the value &lt;code&gt;'A'&lt;/code&gt; to the variable  &lt;code&gt;l&lt;/code&gt; but the byte will not hold a letter &lt;code&gt;'A'&lt;/code&gt;, it will hold ascii code, which is 65 (man ascii).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fak058bgcspefmgfsg7bq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fak058bgcspefmgfsg7bq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;int&lt;/code&gt; and &lt;code&gt;float&lt;/code&gt; case we use 4 bytes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int n;  

n = 8;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5mumd5b3xr32vreq8mo7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5mumd5b3xr32vreq8mo7.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&amp;amp; operator&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;when we want to find the address of a variable we use the &amp;amp; operator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7bs150mfu66cem4a9yd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7bs150mfu66cem4a9yd.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdvhqzcgjng2k766w22b6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdvhqzcgjng2k766w22b6.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The modifier &lt;code&gt;%p&lt;/code&gt; is used to print address &lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  #Storing memory addresses
&lt;/h2&gt;

&lt;p&gt;Up to now we learned how to store a character, decimal and floats in a variable.&lt;/p&gt;

&lt;p&gt;We also learned how to get the address of variable using &lt;code&gt;&amp;amp;&lt;/code&gt; operator.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;pointer&lt;/strong&gt; is simply the address of a piece of data in memory.&lt;br&gt;
&lt;strong&gt;pointer variable&lt;/strong&gt; is a variable that stores the address of that piece of data.&lt;/p&gt;

&lt;p&gt;To declare a pointer variable&lt;/p&gt;

&lt;p&gt;&lt;code&gt;VARIBALE_TYPE *VARIABLE_NAME&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;char *p;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fykikacvnildnyt6ybjez.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fykikacvnildnyt6ybjez.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyt0bg9jircfgg26ovbpl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyt0bg9jircfgg26ovbpl.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A pointer variable holds the address of other variable data&lt;br&gt;
A pointer variable has a size of 8 byte&lt;br&gt;
A pointer variable has his own variable address&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg00ryspzc33g4tay6ycn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg00ryspzc33g4tay6ycn.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int n;
int *p; 

n = 10;
p = &amp;amp;n; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28yosacso8hp9got6ah0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F28yosacso8hp9got6ah0.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now the address of n is 3 and the address of n is &amp;amp;n, So we stored the address of n in p pointer variable.&lt;br&gt;
In this example the the address of n is 3,then the value of p is 3 which holds the address of n.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcoefkcm2inwmh5c778jq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcoefkcm2inwmh5c778jq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0d7lkdb28m695dvq1j76.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0d7lkdb28m695dvq1j76.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F358a3mhs4gsyayluudqt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F358a3mhs4gsyayluudqt.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  #Dereferencing
&lt;/h2&gt;

&lt;p&gt;Dereferencing is a way of using pointers manipulate values stored at the memory address they point to.&lt;/p&gt;

&lt;p&gt;We use the * dereference operator to Dereference the value.&lt;/p&gt;

&lt;p&gt;First off * has two functions&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;used in the declaration. e.g &lt;code&gt;int *p;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;used in dereferencing. e.g &lt;code&gt;*p = 20;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int n;
int *p;

n = 11;
p = &amp;amp;n;
*p = 20; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So now: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;p == &amp;amp;n&lt;/code&gt; holds the address of n&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;*p == n&lt;/code&gt; points the value of n&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let's break this example using the memory representation.&lt;/p&gt;

&lt;p&gt;Up to the part n = 11 and p = &amp;amp;n = 7 the memory representation is &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl1nnusy5a71fhf5y25l2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl1nnusy5a71fhf5y25l2.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fert2bl0nlutnf1hm5miu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fert2bl0nlutnf1hm5miu.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After dereferencing &lt;code&gt;*p = 20&lt;/code&gt; the memory will look like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3bxkzgzahlemk1j6r8e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3bxkzgzahlemk1j6r8e.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq49sucft0gvlfzz2hz7f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq49sucft0gvlfzz2hz7f.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsuv3dei0c782w4irvxge.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsuv3dei0c782w4irvxge.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fblfunef0di5wgkwszpah.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fblfunef0di5wgkwszpah.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  #Functions parameters are passed by value
&lt;/h2&gt;

&lt;p&gt;We have covered in the c function blog post that there are two way of passing parameter in functions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Pass by value: passing the copy of the variable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pass by reference: passing the pointer to the variable.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pass by value&lt;/strong&gt;: this method only copies the value of the variable in the main function and the change made in the other function doesn't affect the value in the main function because it is just a copy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9uz9u7n94bavfwg6ug37.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9uz9u7n94bavfwg6ug37.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before the execution of &lt;code&gt;i = 20;&lt;/code&gt; the memory layout looks like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnomvri5at5qjaai4n3w4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnomvri5at5qjaai4n3w4.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk2n88jetmhf0cfpknpq4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk2n88jetmhf0cfpknpq4.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the execution of the &lt;code&gt;i = 20;&lt;/code&gt; the memory layout will look like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqk6gl35rt6j1d8of5ihq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqk6gl35rt6j1d8of5ihq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdss3o8hrkeemdd6fl64g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdss3o8hrkeemdd6fl64g.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the fun is done executing the variable i is removed and the memory layout looks like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnes3hqiz89zeqj2scmlq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnes3hqiz89zeqj2scmlq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv00e0dlf536290d2vrlo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv00e0dlf536290d2vrlo.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To modify a variable from outside the function it is declared, using a pointer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F643mxluo4r3nze9fxit6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F643mxluo4r3nze9fxit6.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before the function fun the memory layout looks like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F167ka6mex0s3wc2ze9p5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F167ka6mex0s3wc2ze9p5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwi7keu9zz0c86i90lnny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwi7keu9zz0c86i90lnny.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
when we call the function fun the value of &lt;code&gt;p&lt;/code&gt; is  stored in a new variable called  &lt;code&gt;i&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffqlaqz0bn3uigc7chu9h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffqlaqz0bn3uigc7chu9h.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjx4tba8m0kzhqvsxxiom.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjx4tba8m0kzhqvsxxiom.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since i stores the same memory address, it points to the same address, and so both p and i now point to n. Therefore, when we execute the line *i = 20; we modify the value of n and n now holds 20.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F897npji10qpj3wfbqgif.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F897npji10qpj3wfbqgif.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpmwqg21zdb2yki3woi77.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpmwqg21zdb2yki3woi77.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we leave the function fun, the variable i is destroyed, but i’s value is still 20&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4jjs6evrvoz1n83ltomv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4jjs6evrvoz1n83ltomv.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8rk52k1l7a1ckh6q4vyx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8rk52k1l7a1ckh6q4vyx.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  #Arrays
&lt;/h2&gt;

&lt;p&gt;Arrays in C are contiguous memory areas that hold a number of values of the same type and all elements of an array have the same type.&lt;/p&gt;

&lt;p&gt;To declare an array&lt;/p&gt;

&lt;p&gt;&lt;code&gt;TYPE ARRAY_NAME[ARRAY_SIZE];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To assign a value&lt;br&gt;
&lt;code&gt;TYPE ARRAY_NAME[ARRAY_SIZE] = {ELEMENTS}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int arr[5];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;arr[0] will access the first element, arr[1] the second element, and so on. &lt;/p&gt;

&lt;p&gt;In this example the computer will reserve a continuous space for 5 integers in memory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbf42wmg79n5slztxevze.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbf42wmg79n5slztxevze.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqxh2erfefm015gqah4z2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqxh2erfefm015gqah4z2.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The memory layout will look like &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz6zup9egq2z4h1k5sh19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz6zup9egq2z4h1k5sh19.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  #Pointers vs Arrays
&lt;/h2&gt;

&lt;p&gt;Arrays are not pointers they don't hold memory address, But the name of an array is the address of the first element of the array. &lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxfyd3tojzgemoyiy3ca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxfyd3tojzgemoyiy3ca.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48nip2pfzpo89srynd07.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48nip2pfzpo89srynd07.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So why this it outputting the address, when an array &lt;code&gt;a&lt;/code&gt;  is used in an expression the array type gets automatically implicitly converted to pointer-to-element type(array type decay).&lt;/p&gt;

&lt;p&gt;There are two exceptions to this rule in two cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sizeof()&lt;/code&gt; operator&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3rhcq47wh0z2t2upbrmj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3rhcq47wh0z2t2upbrmj.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8rc3vkt96ulkev7oqps9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8rc3vkt96ulkev7oqps9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;amp;&lt;/code&gt; operator&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fua455p8yzs08p36o81n2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fua455p8yzs08p36o81n2.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxq5gpk3jzyt9xdqb0b7i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxq5gpk3jzyt9xdqb0b7i.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  #Pointers Arithmetic
&lt;/h2&gt;

&lt;p&gt;We can access the elements of an array using a different method as *(var + x), where var is the name of an array, and x is the (x+1)th element.&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffhtqxuvpmbnhjrsqor92.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffhtqxuvpmbnhjrsqor92.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyl3j2pcdmh5b6phtz9lw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyl3j2pcdmh5b6phtz9lw.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The memory is a layout&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwuevlj4g3v1ejn930wc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwuevlj4g3v1ejn930wc.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  #Strings
&lt;/h2&gt;

&lt;p&gt;Strings are actually one-dimensional array of characters terminated by a null character '\0'.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;TYPE STRING_NAME[SIZE] = {ELEMENT}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99o02w79juak6exaye3e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99o02w79juak6exaye3e.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnrh2q81yfhirtiy4nx3f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnrh2q81yfhirtiy4nx3f.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You probably notice that we used an array with a size of 6,this is because in C, strings end with the char '\0' (ascii value = 0). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1d3dntglm61cmi25rwkx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1d3dntglm61cmi25rwkx.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  #Memory Layout of C program
&lt;/h2&gt;

&lt;p&gt;Memory layout of C program contains five segments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;stack segment&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;heap segment&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;BSS (block started by symbol)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DS (Data Segment)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;text segment&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each segment has own read, write and executable permission. If a program tries to access the memory in a way that is not allowed then &lt;strong&gt;segmentation fault&lt;/strong&gt;, which is a common problem that causes programs to crash.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnw3fp4d5qb2b9u22qd2m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnw3fp4d5qb2b9u22qd2m.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;stack&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The stack contains local variables from functions, return value and each function has one stack frame.&lt;br&gt;
The stack contains a LIFO(last in first out) structure, Function variables are pushed onto the stack when called and functions variables are popped off the stack when return.&lt;/p&gt;

&lt;p&gt;To understand how LIFO work check out the stack data structure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
int main(void)
{
    int data; //local variable stored in stack
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Heap&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Heap is used to allocate the memory at run time and heap area managed by the memory management functions like malloc, calloc, free, etc&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
int main(void)
{
    char *pStr = malloc(sizeof(char)*4); //stored in heap
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;BSS(Uninitialized data segment)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It contains all uninitialized global and static variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

int data1; 
// Uninitialized global variable stored in BSS

int main(void)
{
    static int data2;
    // Uninitialized static variable stored in BSS
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;DS(Initialized data segment)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It contains the explicitly initialized global and static variables and this segment can be further classified into an initialized read-only area and an initialized read-write area.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

int data1 = 10 ; 
//Initialized global variable stored in DS
int main(void)
{
    static int data2 = 3;  
    //Initialized static variable stored in DS
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Text&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The text segment contains a binary of the compiled program and he text segment is a read-only segment that prevents a program from being accidentally modified.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt; 

int main(void) 
{ 
    return 0; 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl0haf3y8weiv7gh6ciw1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl0haf3y8weiv7gh6ciw1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: &lt;code&gt;NULL&lt;/code&gt; is for pointers which is the absence of address and '\0' is the is for strings&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>c</category>
      <category>pointers</category>
      <category>arrays</category>
      <category>string</category>
    </item>
    <item>
      <title>C - Debugging</title>
      <dc:creator>Haile Melaku</dc:creator>
      <pubDate>Mon, 19 Sep 2022 09:01:07 +0000</pubDate>
      <link>https://dev.to/haile08/c-debugging-191o</link>
      <guid>https://dev.to/haile08/c-debugging-191o</guid>
      <description>&lt;h2&gt;
  
  
  # What is debugging
&lt;/h2&gt;

&lt;p&gt;A 'bug' is a metaphor for a glitch in your program that might crash or exploit your program on use.   &lt;/p&gt;

&lt;p&gt;Debugging is the practice of finding and fixing a bug in programs, software, or systems that prevents it from running correctly.&lt;/p&gt;

&lt;p&gt;A common practice for debugging is printing data of the program to the console.&lt;/p&gt;

&lt;p&gt;The term debugging was first coined by a woman named Admiral Grace Hopper. She found a Moth in the computer's relay which impeded operation. By removing it she said she 'debugged' the system, or something to that effect.&lt;/p&gt;




&lt;h2&gt;
  
  
  # What are some methods of debugging manually
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Rubber Duck Debugging&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Rubber Duck Debugging is a way of explaining you code and the process to rubber duck to find and fix a bug in the system.&lt;/p&gt;

&lt;p&gt;There are only three simple steps to rubber ducking:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Assume your duck knows absolutely nothing about your problem. State the problem, how things are sitting at the moment, and what you are trying to accomplish instead. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explain the flow of things. What happened? Go over every single step of the process without missing out on a single detail. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Arrive at a realization of the fix.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: for more info on how to use rubber duck read this &lt;a href="https://www.thoughtfulcode.com/rubber-duck-debugging-psychology/"&gt;article&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




</description>
      <category>c</category>
      <category>debug</category>
      <category>programming</category>
      <category>debugging</category>
    </item>
    <item>
      <title>C - Functions, nested loops</title>
      <dc:creator>Haile Melaku</dc:creator>
      <pubDate>Sun, 18 Sep 2022 18:18:27 +0000</pubDate>
      <link>https://dev.to/haile08/c-functions-nested-loops-442c</link>
      <guid>https://dev.to/haile08/c-functions-nested-loops-442c</guid>
      <description>&lt;p&gt;Now we are going to see how we use nested loops and function in c.&lt;/p&gt;




&lt;h2&gt;
  
  
  # C - Nested loops
&lt;/h2&gt;

&lt;p&gt;Nested loop is a way of adding a loop inside a loop and the syntax for a nested loops are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nested for loop syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for ( initialization; condition; increment ) {

   for ( initialization; condition; increment ) {

      // statement of inside loop
   }

   // statement of outer loop
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Nested while loop syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while(condition) {

   while(condition) {

      // statement of inside loop
   }

   // statement of outer loop
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Nested do while loop syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;do{

   do{

      // statement of inside loop
   }while(condition);

   // statement of outer loop
}while(condition);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

/**
 * main - Entry point
 * Description: nested loop
 *
 *Return: Always 0 (Success)
 */

int main(void)
{
       int i,j;

       printf("Nested for loop with @\n");
       for (i = 0;i &amp;lt; 10; i++)
       {
            for(j = 0;j &amp;lt; 10; j++)
            {
                    printf("@");
            }
            printf("\n");
       }
       return (0);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cfDr1zWt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7eg9iw60e2bybr941kqy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cfDr1zWt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7eg9iw60e2bybr941kqy.png" alt="Image description" width="880" height="285"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All the loops have one thing in common, that is once one loop of the outside loop is active then the inner loop starts to activate, the second loop of the outside loop won't be activated until the inner loop finishes.&lt;/p&gt;




&lt;h2&gt;
  
  
  # C - Functions
&lt;/h2&gt;

&lt;p&gt;A function is a group of statements that are designed to perform a certain task.&lt;/p&gt;

&lt;p&gt;Most of the time functions are used to divide up our code into simpler parts that make the code easier to read and debug. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;void&lt;/strong&gt;: is used to indicate that a function don't need a return value.&lt;/p&gt;

&lt;p&gt;Syntax&lt;/p&gt;

&lt;p&gt;&lt;code&gt;void FUNCTION_NAME( PARAMETER ){}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Functions must be declared before usage.&lt;/p&gt;

&lt;p&gt;A function declaration tells the compiler about a function's name, return type, and parameters. A function definition provides the actual body of the function.&lt;/p&gt;

&lt;p&gt;Now that we understood the basic concepts of functions let's see the anatomy one by one.&lt;/p&gt;

&lt;p&gt;Example: a function that add two numbers, we are going to be using this example all throughout this course. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--phWOztbZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tnojq18y4yxl1bjmjcxs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--phWOztbZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tnojq18y4yxl1bjmjcxs.png" alt="Image description" width="613" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function prototype (signature of the function)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Function prototype is used to specify the input/output interface of the function, what to input and what return to expect.&lt;/p&gt;

&lt;p&gt;In the example given above the function prototype is &lt;br&gt;
&lt;code&gt;int add(int a, int b)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This prototype is used to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Specify the return type of the function.e.g on this example we get int value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Specify the number and data type of the arguments given to the function. e.g this example has 2 argument and both have an int data type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Specify the name of the function. in the example the function is named &lt;strong&gt;add&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;automatic variable&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This are the variable that are declared inside the function and are only access in the scope of the function.&lt;/p&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int add(int a,int b)
{
       int c = 1;
       return (a + b + c);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example the &lt;code&gt;int c = 1&lt;/code&gt; is an automatic variables and only available in the scope of the function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Return value&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Are the values returned by the function.&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;&lt;code&gt;return (a + b);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If we don't specify a data type for the return value of the function the compiler will place an int data type by default&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add ( int a, int b)
{
  return(a + b);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By Default this is an int return type&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;function invocation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This the calling or usage of the function from the other function statement.&lt;/p&gt;

&lt;p&gt;To call a function, you simply need to pass the required parameters along with the function name, and if the function returns a value, then you can store the returned value.&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;&lt;code&gt;add(5,6)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Forward  Declaration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Is the defalcation of a function before or after defining a function by using prototype.&lt;/p&gt;

&lt;p&gt;Example&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gWBzt56H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bchsmmw4k9honee5jzg1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gWBzt56H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bchsmmw4k9honee5jzg1.png" alt="Image description" width="609" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This future of a function is mainly used in Header file and we will be covering it in the next topic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function Arguments&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Arguments are values that are accepted through the function parameter.&lt;/p&gt;

&lt;p&gt;There are two ways in which arguments can be passed to a function:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Call by value&lt;/strong&gt;: in this case the value passed as an argument is just the copies of the actual values, Making a change to the value in the function doesn't change the argument in the parent function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Call by reference&lt;/strong&gt;: in this case the value passed as an argument is the address of  the actual values, Making a change  to the value in the function affects or changes the argument in the parent function.  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Arrays are always going to be called by reference that means they are passed by address.&lt;/p&gt;

&lt;p&gt;We will dive deeper into call by reference in the C - pointers.&lt;/p&gt;




&lt;h2&gt;
  
  
  # C - Header Files
&lt;/h2&gt;

&lt;p&gt;A header file is a file with &lt;strong&gt;.h&lt;/strong&gt; extension which contains C function prototype and macro definitions to be shared between several source files.&lt;/p&gt;

&lt;p&gt;Including a header file is like copying the content of the header file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;syntax&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For system header files &lt;br&gt;
&lt;code&gt;#include &amp;lt;file.h&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It searches for a file named 'file.h' in a standard list of system directories. &lt;/p&gt;

&lt;p&gt;For your own custom header files&lt;br&gt;
&lt;code&gt;#include "file.h"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It searches for a file named 'file.h' in the directory containing the current file&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating a Header&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To create a header file we include this syntax&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#ifndef HEADER_FILE_NAME
#define HEADER_FILe_NAME

the entire header file file

#endif
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>c</category>
      <category>programming</category>
      <category>functions</category>
      <category>loop</category>
    </item>
    <item>
      <title>C - Variables, if, else, while</title>
      <dc:creator>Haile Melaku</dc:creator>
      <pubDate>Wed, 14 Sep 2022 11:25:03 +0000</pubDate>
      <link>https://dev.to/haile08/c-variables-if-else-while-d76</link>
      <guid>https://dev.to/haile08/c-variables-if-else-while-d76</guid>
      <description>&lt;p&gt;We have seen in the past blog about c compilation process, gcc compiler and some basic c language syntax.&lt;/p&gt;

&lt;p&gt;Now we are going to see more on variables, if statement, arithmetic operation and while statement.&lt;/p&gt;




&lt;h2&gt;
  
  
  # Keywords and identifiers
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;keywords&lt;/strong&gt;: are predefined function names that has a specific purpose and they cannot be used as identifiers in the program.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VQFTM7VU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0lchq6yhbp738sn0h3k5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VQFTM7VU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0lchq6yhbp738sn0h3k5.png" alt="Image description" width="394" height="219"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Identifiers&lt;/strong&gt;: c identifiers are names used to refer to a number of things like variable and functions.&lt;/p&gt;

&lt;p&gt;Identifiers must start with an alphabetic character.&lt;/p&gt;

&lt;p&gt;If you want to be sure that your programs are portable in the new c standard, identifiers need to have a characters limit if 31.&lt;/p&gt;




&lt;h2&gt;
  
  
  # Arithmetic Operators
&lt;/h2&gt;

&lt;p&gt;Are used to used to perform mathematical operations on the given expressions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w-RlKsvq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5wgbehx0hr99oolx2qk0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w-RlKsvq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5wgbehx0hr99oolx2qk0.png" alt="Image description" width="880" height="316"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

/**
 * main - Entry point
 * 
 * Description: print result of arithmetic operator
 * 
 * Return: Always 0 (Success)
 */

int main(void)
{
     int a = 5;
     int b = 15;
     int c;

     c = a + b;
     printf("a + b = %d", c);
     c = a % b;
     printf("a % b = %d", c);

     return (0);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  # relational operators
&lt;/h2&gt;

&lt;p&gt;Are used to perform comparisons on two variable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NfBCgttb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u04pkgtrg196acotlroa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NfBCgttb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u04pkgtrg196acotlroa.png" alt="Image description" width="880" height="440"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

/**
 * main - Entry point
 * 
 * Description: print result of arithmetic operator
 * 
 * Return: Always 0 (Success)
 */

int main(void)
{
     int a = 5;
     int b = 15;

     if ( a &amp;gt;= b )
     {
           printf("a is greater than or equal to b");
      }

      return (0);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  # logical operators
&lt;/h2&gt;

&lt;p&gt;Are used to perform logical operations on the given expressions and there are 3 types of logical operator in c, like logical AND (&amp;amp;&amp;amp;), logical OR (||) and logical NOT (!).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6TAW_gXU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bsv8253pxnblqprycmx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6TAW_gXU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bsv8253pxnblqprycmx.png" alt="Image description" width="691" height="265"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

/**
 * main - Entry point
 * 
 * Description: print result of arithmetic operator
 * 
 * Return: Always 0 (Success)
 */

int main(void)
{
     int a = 5;
     int b = 15;

     if ( a &amp;gt;= b &amp;amp;&amp;amp; a = b)
     {
           printf("both statement's are true");
      }

      return (0);
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  # Bitwise Operators
&lt;/h2&gt;

&lt;p&gt;Are used to perform bit-level operations in C programming.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--n22BHgCC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/43o8gatgbgutr6fwle17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n22BHgCC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/43o8gatgbgutr6fwle17.png" alt="Image description" width="783" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First you need to revise on how to turn binary into decimal and turn the decimal to binary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Binary to decimal&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E2pq1gfs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jwlnkchze0hl51pilj1v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E2pq1gfs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jwlnkchze0hl51pilj1v.png" alt="Image description" width="317" height="243"&gt;&lt;/a&gt; &lt;br&gt;
&lt;strong&gt;Decimal to binary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eiTwkpH0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8sjznkfk0szrrz398xfu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eiTwkpH0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8sjznkfk0szrrz398xfu.png" alt="Image description" width="466" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bitwise AND Operator &amp;amp;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;works like the and logical operator the only case we get true is if 2 values are both true.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

/**
 * main - Entry point
 * 
 * Description: Bitwise AND Operator
 * 
 * Return: Always 0 (Success)
 */

int main(void)
{
      int a = 8;
      int b = 21;

      printf("a &amp;amp; b = %d",a&amp;amp;b);

      return (0);
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;8  =  00001000 (Binary)&lt;br&gt;
21 =  00010101 (Binary)&lt;/p&gt;

&lt;p&gt;Bitwise Operation of 8  and 21&lt;/p&gt;

&lt;p&gt;00001000&lt;br&gt;
&amp;amp;00010101&lt;br&gt;
00000000 = 0 (Decimal)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bitwise OR Operator |&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;works like the or logical operator the only case we get false is if both values are false.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

/**
 * main - Entry point
 * 
 * Description: Bitwise OR Operator
 * 
 * Return: Always 0 (Success)
 */

int main(void)
{
      int a = 8;
      int b = 21;

      printf("a | b = %d",a|b);

      return (0);
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;8  =  00001000 (Binary)&lt;br&gt;
21 =  00010101 (Binary)&lt;/p&gt;

&lt;p&gt;Bitwise Operation of 8  and 21&lt;/p&gt;

&lt;p&gt;00001000&lt;br&gt;
|00010101&lt;br&gt;
00011101 = 29 (Decimal)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bitwise XOR (exclusive OR) Operator ^&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;The output is 1(true) if the corresponding bits of two operands are opposite.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

/**
 * main - Entry point
 * 
 * Description: Bitwise XOR (exclusive OR) Operator
 * 
 * Return: Always 0 (Success)
 */

int main(void)
{
      int a = 8;
      int b = 21;

      printf("a ^ b = %d",a^b);

      return (0);
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;8  =  00001000 (Binary)&lt;br&gt;
21 =  00010101 (Binary)&lt;/p&gt;

&lt;p&gt;Bitwise Operation of 8  and 21&lt;/p&gt;

&lt;p&gt;00001000&lt;br&gt;
^00010101&lt;br&gt;
 00011101 =  29 (Decimal)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bitwise Complement Operator ~&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It changes 1 to 0 and 0 to 1, so complement's in c work differently like the bitwise of 10(-10) which is the 2's compliment instead of 245.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

/**
 * main - Entry point
 * 
 * Description: Bitwise Complement Operator
 * 
 * Return: Always 0 (Success)
 */

int main() {

    printf("Output = %d\n",~35);
    printf("Output = %d\n",~-12);
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Right Shift Operator &amp;gt;&amp;gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Shift all bit to the right by a specific number&lt;/p&gt;

&lt;p&gt;10 = 00001010&lt;br&gt;
10 &amp;gt;&amp;gt; 3 = 00000010 &lt;br&gt;
10 &amp;gt;&amp;gt; 0 = 00001010&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

/**
 * main - Entry point
 * 
 * Description: Right Shift Operator
 * 
 * Return: Always 0 (Success)
 */

int main(void)
{
     int i = 10;

     printf("right shift by 3 = %d", i&amp;gt;&amp;gt;3);

     return (0);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Left Shift Operator &amp;lt;&amp;lt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Shift all the bit to the left by a specific number&lt;/p&gt;

&lt;p&gt;10 = 00001010&lt;br&gt;
10 &amp;lt;&amp;lt; 3 = 00001010000&lt;br&gt;
10 &amp;lt;&amp;lt; 0 = 00001010&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

/**
 * main - Entry point
 * 
 * Description: Left Shift Operator
 * 
 * Return: Always 0 (Success)
 */

int main(void)
{
     int i = 10;

     printf("left shift by 3 = %d", i&amp;lt;&amp;lt;3);

     return (0);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  # if, if ... else statements
&lt;/h2&gt;

&lt;p&gt;If statement allows you to control if a program enters a section of code or not based on whether a given condition is true or false.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(boolean_expression 1) {
   /* Executes when the boolean expression 1 is true */
} else if( boolean_expression 2) {
   /* Executes when the boolean expression 2 is true */
} else if( boolean_expression 3) {
   /* Executes when the boolean expression 3 is true */
} else {
   /* executes when the none of the above condition is true */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Diagram&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wGIOrGpg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9a80abd9zmabas10xjl1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wGIOrGpg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9a80abd9zmabas10xjl1.png" alt="Image description" width="460" height="340"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

/**
 * main - Entry point
 *
 * Description: if, if ... else statements
 *
 * Return: Always 0 (Success)
 */

int main(void)
{
   int a = 20;

   if( a == 10 ) 
   {
      /* if condition is true then print the following */
      printf("Value of a is 10\n" );
   } 
   else if( a == 20 ) 
   {
      /* if else if condition is true */
      printf("Value of a is 20\n" );
   } 
   else if( a == 30 ) 
   {
      /* if else if condition is true  */
      printf("Value of a is 30\n" );
   } 
   else 
   {
      /* if none of the conditions is true */
      printf("None of the values is matching\n" );
   }

   return (0);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  # while loop
&lt;/h2&gt;

&lt;p&gt;While loop is used to loop on a statement as long as the given condition is true.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while(condition) {
   statement(s);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Diagram&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dvGzI1JA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9vtrkixi3bqfwfup55xc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dvGzI1JA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9vtrkixi3bqfwfup55xc.png" alt="Image description" width="451" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;

/**
 * main - Entry point
 *
 * Description: while loop statement 
 *
 * Return: Always 0 (Success)
 */

int main(void)
{
     /* local variable definition */
     int a = 0;

     /* while loop execution */
     while( a &amp;lt; 10 ) 
     {
            printf("value of a: %d\n", a);
            a++;
     }

     return (0);
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>c</category>
      <category>programming</category>
      <category>devops</category>
      <category>linux</category>
    </item>
    <item>
      <title>C - Hello, World</title>
      <dc:creator>Haile Melaku</dc:creator>
      <pubDate>Tue, 13 Sep 2022 14:14:31 +0000</pubDate>
      <link>https://dev.to/haile08/c-hello-world-5d8c</link>
      <guid>https://dev.to/haile08/c-hello-world-5d8c</guid>
      <description>&lt;p&gt;C is a imperative (procedural) language that was created by &lt;a href="https://en.wikipedia.org/wiki/Dennis_Ritchie"&gt;Dennis Ritchie&lt;/a&gt; used to develop software like operating systems, databases, compilers, and so on.&lt;/p&gt;

&lt;p&gt;What do we mean when we say imperative (procedural)? We first need to understand different paradigm of programming language and paradigm just means the style in which they are written of structured.&lt;/p&gt;

&lt;p&gt;There are different types programming language paradigm, some of them are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Imperative programming&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Procedural programming&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Declarative programming&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Object-oriented programming&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of these paradigm we just need to know the two of them for c language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Imperative programming&lt;/strong&gt;: a set of instructions that are given to the computer to execute in a given order.&lt;br&gt;
&lt;strong&gt;Procedural Programming&lt;/strong&gt;: is a derivation of imperative programming, adding to it the feature of functions (also known as "procedures" or "subroutines").&lt;/p&gt;


&lt;h2&gt;
  
  
  # Why choose c
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A good amount of embedded programming is done in C (Hardware programming)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;it fastest language that is high level enough to build practical things.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With the appropriate libraries, you can truly use C for anything.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Web Backend Development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Desktop App Development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Game Development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Language/Compiler Development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Operating Systems and Drivers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  # Compilation Process
&lt;/h2&gt;

&lt;p&gt;Before we start learning c language we first need to understand the compilation process and the commands used on each process.&lt;/p&gt;

&lt;p&gt;The tool we are going to be using in this blog to compile c is &lt;strong&gt;gcc&lt;/strong&gt; tool.&lt;/p&gt;

&lt;p&gt;The process of compilation this like this in order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;preprocessor&lt;/strong&gt;: takes the source code(.c file) to generate intermediate file that is sent to compiler.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compiler&lt;/strong&gt;: convert the intermediate code in to assembly code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Assembler&lt;/strong&gt;: convert the assembly code in to an object code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linker&lt;/strong&gt;: link the object code with the necessary library to generate the executable file.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CRrBBmY2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cj5jdu2q6anzn77r4vbv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CRrBBmY2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cj5jdu2q6anzn77r4vbv.jpg" alt="Image description" width="880" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's see each one of them individually.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Preprocessor&lt;/strong&gt;: takes the source file to generate the intermediate file by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Remove the comments&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;include header file's code in the file&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Replace macro names with code&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Source code( .c file)&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nhYuWbAe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ljhwbe2fz00fqt6z0zjz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nhYuWbAe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ljhwbe2fz00fqt6z0zjz.png" alt="Image description" width="544" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gL8bckYn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t0zhupydun21b4tf1m1r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gL8bckYn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t0zhupydun21b4tf1m1r.png" alt="Image description" width="627" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we created the source code we need to preprocess it and we do that by the command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gcc -E &amp;lt;FILE_NAME&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;we can also use the &lt;code&gt;-o&lt;/code&gt; function to output into a file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ih5kBq3d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxeq2p1m1gpvru6aaxj4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ih5kBq3d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxeq2p1m1gpvru6aaxj4.png" alt="Image description" width="781" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compiler&lt;/strong&gt;: takes the source code to convert it into an assembly code and the command we are going to use is:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gcc -c &amp;lt;FILE_NAME&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ld4e5U5Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/new742xqtcoy9wg0vsdt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ld4e5U5Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/new742xqtcoy9wg0vsdt.png" alt="Image description" width="880" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Assembler&lt;/strong&gt;: convert the assembly code into binary code 0's and 1's or machine code and the command we are going to use is:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gcc -S &amp;lt;FILE_NAME&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ngHsBEA6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w0p5rp3cuzqfmb5rorcc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ngHsBEA6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w0p5rp3cuzqfmb5rorcc.png" alt="Image description" width="791" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linker&lt;/strong&gt;: linker's includes some of the library files  into the program to create an executable file and the command we are going to use is:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;gcc &amp;lt;FILE_NAME&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a3hEFFtL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/umykqk0dybmdq92tpfka.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a3hEFFtL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/umykqk0dybmdq92tpfka.png" alt="Image description" width="791" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we learned about the compilation process, we need to understand the gcc compiler.&lt;/p&gt;


&lt;h2&gt;
  
  
  gcc
&lt;/h2&gt;

&lt;p&gt;GCC (GNU Compiler Collections) is a compiler mainly used for C and C++ language.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-o&lt;/code&gt; : is an option to specify the output of the file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pzRlSIv1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x1545rpiqzj7d0lbw706.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pzRlSIv1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x1545rpiqzj7d0lbw706.png" alt="Image description" width="742" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-Werror&lt;/code&gt;: is an option to show the warning if any error is there in the program.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NQgP4gY_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ldg9mr9d9eznn2fn6j15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NQgP4gY_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ldg9mr9d9eznn2fn6j15.png" alt="Image description" width="742" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-Wall&lt;/code&gt;: is an option to show all kind of warning like unused variables errors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eAUIix7p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bebawj33ijpxg33m5qdb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eAUIix7p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bebawj33ijpxg33m5qdb.png" alt="Image description" width="742" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-std=&lt;/code&gt;: is an option to set the standard(version) of c to compile source file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Nv9fmyPt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4w4562y440b27yhe3li3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Nv9fmyPt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4w4562y440b27yhe3li3.png" alt="Image description" width="742" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip : For more information on gcc compiler use the command &lt;code&gt;man gcc&lt;/code&gt; to read the manual. &lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  #C - Hello, world
&lt;/h2&gt;

&lt;p&gt;Now we finished learning about compilation process and gcc compiler, we need to get our hand dirty and start codding in c.&lt;/p&gt;

&lt;p&gt;The first thing we need to do is learn the most common style of writing c language and how to document them,For this course we need to use the Linux kernel coding style &lt;a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/Documentation/process/coding-style.rst"&gt;Linux style&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hello world code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The structure of a hello world code&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V2NzQTX7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rer1uis3400ldg8kkvv1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V2NzQTX7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rer1uis3400ldg8kkvv1.png" alt="Image description" width="627" height="298"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/code&gt; is the header file that define the input output routines used by a program.&lt;br&gt;&lt;br&gt;
&lt;code&gt;int main(void)&lt;/code&gt; is the entry point of our program&lt;br&gt;
&lt;code&gt;printf("Hello world")&lt;/code&gt; is a line that print the text&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Comments&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;used to document you code and some of c language commenting syntax are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* comment  */
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*
 * muti line
 * commnet
 */
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Warning: you can not nest a comment in a comment&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Variables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Used to connect a value to a symbol&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;type&amp;gt; &amp;lt;var_name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Names of variables: [a-zA-z_][a-zA-Z_0-9]*&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int var;
char c;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Data types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9srehKMa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cz7mg95eb0zbq96wkt83.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9srehKMa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cz7mg95eb0zbq96wkt83.png" alt="Image description" width="880" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: for more info on data type read &lt;a href="https://publications.gbdirect.co.uk//c_book/chapter2/integral_types.html"&gt;Data Type&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Modifiers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;some of the modifiers used in c are long, long long,short,unsigned and signed.&lt;/p&gt;

&lt;p&gt;They are used to specify how much space the variable take on memory.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;long, long long&lt;/code&gt; : are used to extend the space used on the system and can be used with int, double.&lt;br&gt;
&lt;code&gt;short&lt;/code&gt;: takes half the space on the system.&lt;br&gt;
&lt;code&gt;signed&lt;/code&gt;: support both positive and negative numbers, we can use it with int, char.&lt;br&gt;
&lt;code&gt;unsigned&lt;/code&gt;: support only positive numbers, we can use it with int,char.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;sizeof()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This function is used to find out how a much size types use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sizeof(char);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Type casting&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Is a way of converting one type of data into another.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;char c = 'a';
int i = 5;

int_num = (int)c;
float_num = (float)i;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we essentially converted the char into int and the int into float.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;pritnf()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Used for printing or writing a statement on to the stdout.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;printf("hello world")

printf("string:%s deciaml:%d float:%f char:%c","name",12,2.6,'C');

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;special symbols like %s,%d and %f are used to represent different data's that are imputed to the right of the main string.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;puts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Does not include null character inputs to write or print to stdout.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;puts("hello world");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;putchar&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Used to write a character, of unsigned char type, to stdout.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;char i = 'a';

putchar(i);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;putchar can sometimes be used to print digit's,To do this we need using ASCII value of '0'.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int i = 10;

putchar(i + '0');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>c</category>
      <category>shell</category>
      <category>gcc</category>
    </item>
    <item>
      <title>Shell, init files, variables and expansions</title>
      <dc:creator>Haile Melaku</dc:creator>
      <pubDate>Thu, 08 Sep 2022 06:41:04 +0000</pubDate>
      <link>https://dev.to/haile08/shell-init-files-variables-and-expansions-36la</link>
      <guid>https://dev.to/haile08/shell-init-files-variables-and-expansions-36la</guid>
      <description>&lt;p&gt;So, today am going to be checking more about shell, more specifically topics on Shell initialization files,variables and shell expansions.&lt;/p&gt;




&lt;h2&gt;
  
  
  #Shell initialization files
&lt;/h2&gt;

&lt;p&gt;When a shell is opened, there are certain initialization/startup files that are read which help to setup an environment for the shell itself and the system user.&lt;/p&gt;

&lt;p&gt;Before we get into shell initialization we need to understand the three mods of the shell when it is opened:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Interactive login&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interactive non-login &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;non-interactive non-login shell&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;non-interactive login shell&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let's see each one in more detail&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Login shell&lt;/strong&gt;: executes under our user ID when we log in to a session.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Interactive shell&lt;/strong&gt;: Reads commands from user input on a terminal.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Interactive Login&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this mode you login in a remote computer.&lt;/p&gt;

&lt;p&gt;for example it can be run through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;using ssh&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Interactive non-login&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this mode you just open a terminal.&lt;/p&gt;

&lt;p&gt;for example it can be run through: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;running /bin/bash&lt;/li&gt;
&lt;li&gt;running /bin/su &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;non-interactive non-login shell&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this mode you run a script, it only opens to execute the script and closes immediately once the script is finished.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;non-interactive login shell&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;In this mode you run a script remotely vi ssh or telnet.&lt;/p&gt;

&lt;p&gt;for example :&lt;br&gt;
&lt;code&gt;echo command | ssh server&lt;/code&gt;&lt;/p&gt;




&lt;p&gt;Now that we understood the concepts of intractability and login ,we need to see the two types of shell initialization files&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;system-wide startup files&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;user-specific startup files&lt;/strong&gt; &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;system-wide startup files&lt;/strong&gt;: are global configuration that apply to all users in the system and are located in the /etc directory.&lt;/p&gt;

&lt;p&gt;Some of them are :&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- /etc/profiles&lt;/strong&gt;: it stores system-wide environment configurations and startup programs for login setup.&lt;/p&gt;

&lt;p&gt;On some systems this file holds pointers to other configuration files such as: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; /etc/inputrc: to configure the command line bell-style.&lt;/li&gt;
&lt;li&gt;/etc/profile.d directory: contain system-wide behavior of specific program  configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JnC8qSam--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xhj2xuimdoh6d94rsnhh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JnC8qSam--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xhj2xuimdoh6d94rsnhh.png" alt="Image description" width="880" height="430"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;- /etc/bashrc or /etc/bash.bashrc&lt;/strong&gt;: it stores system-wide functions and aliases including other configurations that apply to all system users.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lWCelsso--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/axbtp3kj9893upoyf66c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lWCelsso--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/axbtp3kj9893upoyf66c.png" alt="Image description" width="880" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;wuser-specific startup files&lt;/strong&gt;: are store configurations that apply to a single user on the system and located in the users home directory as dot files.&lt;/p&gt;

&lt;p&gt;Some of them in there process are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.bash_profile&lt;/strong&gt; : stores user specific environment and startup programs configurations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.bashrc&lt;/strong&gt; :  Stores user-specific aliases and functions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.bash_login&lt;/strong&gt; : Contains specific configurations that are normally only executed when you log in to the system. When the ~/.bash_profile is absent, this file will be read by bash&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.profiles&lt;/strong&gt; : In the absence of ~/.bash_profile and ~/.bash_login, ~/.profile is read. It can hold the same configurations, which are then also accessible by other shells.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.bash_history&lt;/strong&gt; : Bash maintains a history of commands that have been entered by a user on the system. This list of commands is kept in a user’s home directory in the ~/.bash_history file. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;.bash_logout&lt;/strong&gt; : it’s not used for shell startup, but stores user specific instructions for the logout procedure. It is read and executed when a user exits from an interactive login shell.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: to see the login process use this &lt;a href="https://www.youtube.com/watch?v=yIuPu4iLcY4"&gt;Video&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tip: for more info on this &lt;a href="https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_01.html"&gt;info&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  #Variables
&lt;/h2&gt;

&lt;p&gt;A variable is an abstract storage location paired with an associated symbolic name.&lt;/p&gt;

&lt;p&gt;A shell variable is a variable that is available only to the current shell.&lt;/p&gt;

&lt;p&gt;An environment variable is available system wide and can be used by other applications on the system.&lt;/p&gt;

&lt;p&gt;Bash keeps a list of two types of variables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Global variables&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Local variables&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Global variables&lt;/strong&gt;: are variables that are available to all Bash scripts on your system, we use the commands &lt;strong&gt;env&lt;/strong&gt; or &lt;strong&gt;printenv&lt;/strong&gt; to display environment variables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Local variables&lt;/strong&gt;: are variables that can only be used within the script (or shell) in which they're defined..&lt;/p&gt;

&lt;p&gt;To &lt;strong&gt;create&lt;/strong&gt; a shell variable we use the following command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;NAME='VALUE'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;export&lt;/strong&gt; : we can use the export command to export variables to the child-processes.&lt;/p&gt;

&lt;p&gt;to view all the exported variables ,we use the command &lt;/p&gt;

&lt;p&gt;&lt;code&gt;export -p&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And to export the variables, we use the command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;export NAME='VALUE'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reserved variable&lt;/strong&gt; are set or used by Bash, but other shells do not normally treat them specially.&lt;/p&gt;

&lt;p&gt;Some examples of reserved variable are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HOME&lt;/strong&gt; : The current user's home directory; the default for the cd built-in. The value of this variable is also used by tilde expansion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PATH&lt;/strong&gt; : A colon-separated list of directories in which the shell looks for commands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PS1&lt;/strong&gt; :   The primary prompt string. The default value is "'\s-\v\$ '". &lt;/p&gt;




&lt;h2&gt;
  
  
  #Expansion
&lt;/h2&gt;

&lt;p&gt;Expansion is the process of Performed upon the text before it carries out our command.&lt;/p&gt;

&lt;p&gt;There are many kinds of Expansions performed, some of them are:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pathname Expansion&lt;/strong&gt;: is mechanism by which wildcards work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HMM_9fsC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5sj5kau8zxitwyvpcijt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HMM_9fsC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5sj5kau8zxitwyvpcijt.png" alt="Image description" width="776" height="154"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Tilde(~) Expansion&lt;/strong&gt;: When used at the beginning of a word, it expands into the home directory of the current user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--coiAuNm2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yiltlt36h8o7jaulq9sb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--coiAuNm2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yiltlt36h8o7jaulq9sb.png" alt="Image description" width="776" height="154"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Arithmetic Expansion&lt;/strong&gt;: a mechanism to perform arithmetic on the shell.&lt;br&gt;
&lt;code&gt;$((expression))&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To see all arithmetic expansion read this &lt;a href="https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html"&gt;Docum&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_a-B2tdZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3nsyvggn2u3tbtsf4jsy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_a-B2tdZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3nsyvggn2u3tbtsf4jsy.png" alt="Image description" width="776" height="154"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HorOFyw_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26b18omj2jd84zwe1gkg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HorOFyw_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26b18omj2jd84zwe1gkg.png" alt="Image description" width="776" height="154"&gt;&lt;/a&gt;&lt;br&gt;
 &lt;strong&gt;Brace Expansion&lt;/strong&gt;: We use the expression in the brace to generate multiple text strings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BAEX0sR2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3jx5515dektnaewy2ta9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BAEX0sR2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3jx5515dektnaewy2ta9.png" alt="Image description" width="776" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kX5j-DtK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8ax5e5r8fvd7zw9sb2p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kX5j-DtK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o8ax5e5r8fvd7zw9sb2p.png" alt="Image description" width="776" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FGM1NmXJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2l2rxm25v500qpk1dla5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FGM1NmXJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2l2rxm25v500qpk1dla5.png" alt="Image description" width="776" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Parameter Expansion&lt;/strong&gt;: the use of variables to expand.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BZ3J06fC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a58nao196t6hjxw38h5r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BZ3J06fC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a58nao196t6hjxw38h5r.png" alt="Image description" width="776" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This are some of the expansions used Linux&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Command Substitution&lt;/strong&gt;: is able to output a command as an expansion.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5_BlUQoi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9b9i20hwzdtjm0gbkagf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5_BlUQoi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9b9i20hwzdtjm0gbkagf.png" alt="Image description" width="776" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: for more info on expansion read &lt;a href="http://linuxcommand.org/lc3_lts0080.php"&gt;article&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  alias
&lt;/h2&gt;

&lt;p&gt;alias is a linux command used to create custom made linux commands.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;alias [alias-name[=string]...]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--W4Yy6iRg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jsen3e5zzq9i6fseobqo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W4Yy6iRg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jsen3e5zzq9i6fseobqo.png" alt="Image description" width="776" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: for more info on alias read &lt;a href="http://www.linfo.org/alias.html"&gt;alias&lt;/a&gt; or use the command &lt;strong&gt;man alias&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>variables</category>
      <category>linux</category>
      <category>shell</category>
      <category>bash</category>
    </item>
    <item>
      <title>Shell, I/O Redirections and filters</title>
      <dc:creator>Haile Melaku</dc:creator>
      <pubDate>Tue, 06 Sep 2022 09:56:03 +0000</pubDate>
      <link>https://dev.to/haile08/shell-io-redirections-and-filters-4bbo</link>
      <guid>https://dev.to/haile08/shell-io-redirections-and-filters-4bbo</guid>
      <description>&lt;p&gt;Today we are going to touch on some more Linux shell topics such as i/o stream, filters and pips.&lt;/p&gt;




&lt;h2&gt;
  
  
  #I/O Redirection
&lt;/h2&gt;

&lt;p&gt;I/O redirection is the redirecting of input and output of many commands to files, devices, and even to the input of other commands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Streams&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Input and output in the Linux environment is distributed across three streams:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;standard input (stdin) (0)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;standard output (stdout) (1)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;standard error (stderr) (2)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Standard Input&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The standard input moves data form user or keyboard to program.&lt;br&gt;
To do this we use the notation for the input standard, &amp;lt; and  &amp;lt;&amp;lt; have different functionality one has: &lt;/p&gt;

&lt;p&gt;Overwrite&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&amp;lt; - standard input&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Append&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&amp;lt;&amp;lt;    - standard input&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gTtwufVO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vonw0mmfpghjxnhtj9fw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gTtwufVO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vonw0mmfpghjxnhtj9fw.png" alt="Image description" width="474" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Standard Output&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The standard output is the output generated by a program, it will output text directly to the terminal or a file.&lt;br&gt;
To do this we use the notation for the output standard, &amp;gt; and  &amp;gt;&amp;gt; have different functionality one has:&lt;/p&gt;

&lt;p&gt;Overwrite&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&amp;gt; - standard output&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Append&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&amp;gt;&amp;gt; - standard output&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I2jhMr0L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ah5yl77dmyh9rb0jxduz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I2jhMr0L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ah5yl77dmyh9rb0jxduz.png" alt="Image description" width="474" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Standard Error&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The standard error is s errors generated by a program that has failed in some way.&lt;br&gt;
To do this we use the notation for the error standard, 2&amp;gt; and 2&amp;gt;&amp;gt; have different functionality one has:&lt;/p&gt;

&lt;p&gt;Overwrite&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;2&amp;gt; - standard error&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Append&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;2&amp;gt;&amp;gt; - standard error&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y7Y7o6oQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9fth31jlgn9dk52bxub.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y7Y7o6oQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9fth31jlgn9dk52bxub.png" alt="Image description" width="474" height="115"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l7jGHbDZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4wfjwbxf9w7o19shcfb7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l7jGHbDZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4wfjwbxf9w7o19shcfb7.png" alt="Image description" width="880" height="118"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: for more info read &lt;a href="http://linuxcommand.org/lc3_lts0070.php"&gt;i/o redirect&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  #Pipelines
&lt;/h2&gt;

&lt;p&gt;Pipes are used to redirect a stream from one program to another and it connects multiple commands together.&lt;/p&gt;

&lt;p&gt;What that mean is pips work like an assembly line in factory once one program runs and outputs then that output is moved through the pip to the second command.&lt;/p&gt;

&lt;p&gt;We declare a pip using this command&lt;br&gt;
&lt;code&gt;|&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iyhjpxoK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/18509uaxselr55d1595c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iyhjpxoK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/18509uaxselr55d1595c.png" alt="Image description" width="673" height="120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What this command do is it takes the output of ls -la then display it using less.&lt;/p&gt;




&lt;h2&gt;
  
  
  #Filters
&lt;/h2&gt;

&lt;p&gt;Filters are mostly used with pips.Filters take standard input and perform an operation upon it and send the results to standard output.&lt;/p&gt;

&lt;p&gt;Here are some of the common programs that can act as filters:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;find&lt;/strong&gt; - returns files with filenames that match the argument passed to find.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;grep&lt;/strong&gt; - returns text that matches the string pattern passed to grep.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;tr&lt;/strong&gt; - finds-and-replaces one string with another.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;wc&lt;/strong&gt; - counts characters, lines, and words.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  #Commands
&lt;/h2&gt;

&lt;p&gt;Now that we seen these concepts we need to see some common Linux commands and programs we will be using in this topic.&lt;/p&gt;




&lt;h2&gt;
  
  
  echo
&lt;/h2&gt;

&lt;p&gt;we use the command echo display a line of text and to write into a file using i/o streams.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;echo [SHORT-OPTION]... [STRING]...&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7MtpP8Nj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rmk06c6oz4dqqtwr1tc3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7MtpP8Nj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rmk06c6oz4dqqtwr1tc3.png" alt="Image description" width="845" height="129"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We use with the stream&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WBJtBVUd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y36kpzuu5x0n9xtvtev3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WBJtBVUd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y36kpzuu5x0n9xtvtev3.png" alt="Image description" width="845" height="129"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We need special characters to string &lt;a href="http://mywiki.wooledge.org/BashGuide/SpecialCharacters"&gt;char&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BNJt0dU7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpjf6wsz57vq3i56fpeq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BNJt0dU7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpjf6wsz57vq3i56fpeq.png" alt="Image description" width="700" height="55"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: for more info use the command &lt;strong&gt;man echo&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  cat
&lt;/h2&gt;

&lt;p&gt;we use the command cat to concatenate files and print on the standard output.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cat [OPTION]... [FILE]...&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  head
&lt;/h2&gt;

&lt;p&gt;we use the command head to output the first part of files.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;head [OPTION]... [FILE]...&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  tail
&lt;/h2&gt;

&lt;p&gt;we use the command tail to output the last part of files.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tail [OPTION]... [FILE]...&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  find
&lt;/h2&gt;

&lt;p&gt;we use the command find to search for files in a directory hierarchy.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;find  [-H]  [-L]  [-P] [-D debugopts] [-Olevel] [starting-point...]     [expression]&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  wc
&lt;/h2&gt;

&lt;p&gt;we use the command to print newline, word, and byte counts for each file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wc [OPTION]... [FILE]...&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  sort
&lt;/h2&gt;

&lt;p&gt;we use the command to sort lines of text files.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sort [OPTION]... [FILE]...&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  uniq
&lt;/h2&gt;

&lt;p&gt;we use the command to report or omit repeated lines.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;uniq [OPTION]... [INPUT [OUTPUT]]&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  grep
&lt;/h2&gt;

&lt;p&gt;we use the command to print lines that match patterns.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;grep [OPTION...] PATTERNS [FILE...]&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  tr
&lt;/h2&gt;

&lt;p&gt;we use the command to translate or delete characters.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tr [OPTION]... SET1 [SET2]&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  rev
&lt;/h2&gt;

&lt;p&gt;we use the command to reverse lines characterwise.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rev [option] [file...]&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  cut
&lt;/h2&gt;

&lt;p&gt;we use the command to remove sections from each line of files.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cut OPTION... [FILE]...&lt;/code&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
      <category>pips</category>
      <category>shell</category>
    </item>
  </channel>
</rss>
