<?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: Dave Mcsavvy </title>
    <description>The latest articles on DEV Community by Dave Mcsavvy  (@mcsavvy).</description>
    <link>https://dev.to/mcsavvy</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%2F746319%2Fe688f657-0036-497b-98f4-1e45d8767e84.jpg</url>
      <title>DEV Community: Dave Mcsavvy </title>
      <link>https://dev.to/mcsavvy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mcsavvy"/>
    <language>en</language>
    <item>
      <title>What Are You Pointing At???</title>
      <dc:creator>Dave Mcsavvy </dc:creator>
      <pubDate>Wed, 21 Sep 2022 06:37:11 +0000</pubDate>
      <link>https://dev.to/mcsavvy/what-are-you-pointing-at-ohc</link>
      <guid>https://dev.to/mcsavvy/what-are-you-pointing-at-ohc</guid>
      <description>&lt;p&gt;&lt;strong&gt;If you really want to kick ass in C, you need to understand how C handles memory&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;The C language gives you a lot more control over how your program uses the computer memory, let's go behind the scenes and see what happens every time you assign, modify or use a variable.&lt;/p&gt;

&lt;h2&gt;
  
  
  C code inludes &lt;u&gt;pointers&lt;/u&gt;
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;To best understand pointers, &lt;em&gt;go slowly&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Pointers are one of the most fundamental things to understand in&lt;br&gt;
the C programming language. So what’s a pointer? A &lt;strong&gt;pointer&lt;/strong&gt; is&lt;br&gt;
just the address of a piece of data in memory.&lt;/p&gt;
&lt;h3&gt;
  
  
  Pointers are useful for the following reasons.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Instead of passing around a whole copy of the data, you can just pass a pointer to the original data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You might want two pieces of code to work on the same piece of data rather than a separate copy.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To illustrate, look at the following code&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jezsoao6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fhu6lbwaibpc7j4eh2ct.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jezsoao6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fhu6lbwaibpc7j4eh2ct.png" alt="Example 1" width="812" height="816"&gt;&lt;/a&gt;&lt;br&gt;
The program starts with n as 100, so if n is increased by 1 it would now be 101. &lt;em&gt;At least it would be if the code works&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Look at the code carefully. Do you think it will work? Why? Why not?&lt;/p&gt;
&lt;/blockquote&gt;




&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; gcc addone.c &lt;span class="nt"&gt;-o&lt;/span&gt; addone
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ./addone
the value of n is 100
the value of n is now 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Hmmm, why didn't our function work?&lt;/strong&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  C sends arguments as &lt;u&gt;values&lt;/u&gt;
&lt;/h3&gt;

&lt;p&gt;The code broke because of the way C calls functions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Initially the main() function has a local variable called n that had value 100&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When the program calls the add_one() function, it copies the value of n from main() to add_one(). This means that even though they look like the same variables, they are not because when you call a function, you don't send the variable as an argument, just it's value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When the add_one() function changes the value of n, the function is just changing its local copy. This means when the computer returns to the main() function, the n variable still has its original value of 100&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But if that's how C calls functions, how can you ever write a function that updates a value?&lt;br&gt;
&lt;strong&gt;It's easy if you use pointers...&lt;/strong&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  Using memory pointers
&lt;/h3&gt;
&lt;h4&gt;
  
  
  1. Get the address of a variable
&lt;/h4&gt;

&lt;p&gt;You can find where a variable is stored in memory using the &lt;code&gt;&amp;amp;&lt;/code&gt; operator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"x lives at %p&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But one you've got the address of a variable, you may want to store it somewhere. To do that, you will need a &lt;strong&gt;pointer variable&lt;/strong&gt;. A pointer variable is just a variable that stores a memory address. When you declare a pointer variable, you need to say what kind of data is stores at the address it will point to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;address_of_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"x lives at %p&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;address_of_x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Read the contents of an address
&lt;/h4&gt;

&lt;p&gt;When you have a memory address, you will want to read the data that's stored there. You do that with the &lt;code&gt;*&lt;/code&gt; operator&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;&amp;amp;&lt;/code&gt; operators are opposites. The &lt;code&gt;&amp;amp;&lt;/code&gt; operator takes a piece of data and tells you where it's stores. The &lt;code&gt;*&lt;/code&gt; operator takes an address and tells you what's stored there.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Because pointers are sometimes called referrences, the &lt;code&gt;*&lt;/code&gt; operator is said to &lt;strong&gt;dereference&lt;/strong&gt; a pointer.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  3. Change the contents of an address
&lt;/h4&gt;

&lt;p&gt;If you have a pointer variable and you want to change the data at the address where the variable's pointing to, you can just use the &lt;code&gt;*&lt;/code&gt; operator again. But this time you need to use it on the &lt;strong&gt;left side&lt;/strong&gt; of an assignment&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;OK, now that you know how to read and write the contents of a memory location(&lt;em&gt;pointer&lt;/em&gt;), it's time for you to fix the add_one() function.&lt;/strong&gt;&lt;/p&gt;

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




&lt;h3&gt;
  
  
  Solution
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l4xb3veu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dhzd8fpdqifmp7i0lwu0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l4xb3veu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dhzd8fpdqifmp7i0lwu0.png" alt="Example 3" width="842" height="846"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; gcc addone.c &lt;span class="nt"&gt;-o&lt;/span&gt; addone
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ./addone
the value of n is 100
the value of n is now 101
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  The code works.
&lt;/h4&gt;

&lt;p&gt;Because the function takes a pointer argument, it’s able to&lt;br&gt;
update the original n variable.&lt;br&gt;
That means that you now know how to create functions that&lt;br&gt;
not only return values, but can also update any memory&lt;br&gt;
locations that are passed to them.&lt;/p&gt;




&lt;h3&gt;
  
  
  BULLET POINTS
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Variable are allocated storage in memory&lt;/li&gt;
&lt;li&gt;Pointers are just variables that store memory addresses&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;&amp;amp;&lt;/code&gt; operator finds the address of a variable&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;*&lt;/code&gt; operator can read the contents of a memory address&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;*&lt;/code&gt; operator can also set the contents of a memory address&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>csharp</category>
      <category>cpp</category>
      <category>c</category>
      <category>programming</category>
    </item>
    <item>
      <title>Understand chars in 5 mins or less</title>
      <dc:creator>Dave Mcsavvy </dc:creator>
      <pubDate>Tue, 13 Sep 2022 01:28:01 +0000</pubDate>
      <link>https://dev.to/mcsavvy/understand-chars-in-5-mins-or-less-2d97</link>
      <guid>https://dev.to/mcsavvy/understand-chars-in-5-mins-or-less-2d97</guid>
      <description>&lt;p&gt;What is the &lt;code&gt;char&lt;/code&gt; type in C and how should it be used.&lt;/p&gt;

&lt;p&gt;Before we dive into these, let's have a quick glance at C types.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types In C
&lt;/h2&gt;

&lt;p&gt;Types are useful to us because they allow us to handle values in a specific way.&lt;br&gt;
In the backend though, C uses types to determine how much memory to allocate for a given value.&lt;br&gt;
C is very particular about memory and it needs to know the type of every value.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Char type
&lt;/h2&gt;

&lt;p&gt;This special type refers to printable and control character - &lt;em&gt;basically every key on your keyboard!&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Declaring Characters
&lt;/h3&gt;

&lt;p&gt;The syntax for declaring a variable as a &lt;code&gt;char&lt;/code&gt; looks like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;character&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'Z'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note that single quotes &lt;code&gt;''&lt;/code&gt; are used instead of double quotes &lt;code&gt;""&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Under the hood, all &lt;code&gt;char&lt;/code&gt; type translate to an integer. So you declare character like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;48&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'0'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can view the a table of all characters and their integer representation &lt;a href="https://www.w3schools.com/charsets/ref_html_ascii.asp#:~:text=ASCII%20is%20a%207%2Dbit,are%20all%20based%20on%20ASCII."&gt;here&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Char Operations
&lt;/h3&gt;

&lt;p&gt;C provides a library for handling characters in an exciting way 🔥&lt;br&gt;
You can use that library by including the &lt;code&gt;ctype.h&lt;/code&gt; library at the top of your script like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;ctype.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are a few utilities the library gives you for free...&lt;/p&gt;

&lt;h3&gt;
  
  
  check is a character is lower case
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;islower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="c1"&gt;// do something &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;islower&lt;/code&gt; returns 1 if a character is lower case, and 0 if it's not.&lt;/p&gt;

&lt;h3&gt;
  
  
  check is a character is upper case
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'A'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isupper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="c1"&gt;// do something &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;isupper&lt;/code&gt; returns 1 if a character is upper case, and 0 if it's not.&lt;/p&gt;

&lt;h3&gt;
  
  
  check is a character is an alphabet
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'A'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isalpha&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="c1"&gt;// do something &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;isalpha&lt;/code&gt; returns 1 if a character is an alphabet, and 0 if it's not.&lt;/p&gt;

&lt;h3&gt;
  
  
  check is a character is a digit
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'4'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isdigit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="c1"&gt;// do something &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;isdigit&lt;/code&gt; returns 1 if a character is a decimal number, and 0 if it's not.&lt;/p&gt;

&lt;h3&gt;
  
  
  check is a character is a digit or alphabet
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'y'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isalphanum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="c1"&gt;// do something &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;isalphanum&lt;/code&gt; returns 1 if a character is a digit or alphabet, and 0 if it's not.&lt;/p&gt;

&lt;p&gt;Bet you can guess what these functions do&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ispunc&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;isspace&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can also convert characters to uppercase and lowercase using &lt;code&gt;toupper&lt;/code&gt; and &lt;code&gt;tolower&lt;/code&gt; respectively.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'A'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Switch case&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isupper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tolower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;islower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;toupper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Spoilers&lt;/strong&gt;&lt;br&gt;
Emojis are also chars!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;char&lt;/span&gt; &lt;span class="n"&gt;damn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sc"&gt;'🥵'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>productivity</category>
      <category>c</category>
    </item>
    <item>
      <title>Meet Betty, The C code linter</title>
      <dc:creator>Dave Mcsavvy </dc:creator>
      <pubDate>Mon, 12 Sep 2022 08:34:31 +0000</pubDate>
      <link>https://dev.to/mcsavvy/meet-betty-the-c-code-linter-1lld</link>
      <guid>https://dev.to/mcsavvy/meet-betty-the-c-code-linter-1lld</guid>
      <description>&lt;p&gt;I need to make this clear - "&lt;em&gt;betty frustrates me!&lt;/em&gt;".&lt;/p&gt;

&lt;p&gt;Over the time though, I've learnt to avoid her and I'll tell you how, but first...&lt;/p&gt;

&lt;h2&gt;
  
  
  Who Is Betty
&lt;/h2&gt;

&lt;p&gt;Betty is actually a very real person 🤯, according to Wikipedia...&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Frances Elizabeth Holberton was an American computer scientist who was one of the six original programmers of the first general-purpose electronic digital computer, ENIAC. The other five ENIAC programmers were Jean Bartik, Ruth Teitelbaum, Kathleen Antonelli, Marlyn Meltzer, and Frances Spence.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But seriously, this isn't the Betty we'll be talking about today.&lt;br&gt;
Betty is a Holberton-style C code checker written in perl.&lt;/p&gt;

&lt;p&gt;Now there's some explanation needed for the above sentence, so I'll start with...&lt;/p&gt;
&lt;h3&gt;
  
  
  Holberton
&lt;/h3&gt;

&lt;p&gt;Holberton is a computer science school founded in silicon valley (&lt;em&gt;that's all you get 😴&lt;/em&gt;)&lt;/p&gt;
&lt;h3&gt;
  
  
  Code Checker
&lt;/h3&gt;

&lt;p&gt;Also known as linter.&lt;br&gt;
Lint, or a linter, is a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs.&lt;/p&gt;

&lt;p&gt;This means that Betty does not have to run or compile your C code before she detects potential errors and wrong styles.&lt;/p&gt;
&lt;h3&gt;
  
  
  Perl
&lt;/h3&gt;

&lt;p&gt;It's just another programming language like C.&lt;br&gt;
Hold on! So Betty is basically a program in one language trying to detect errors in another language 🤦🏾‍♂️&lt;/p&gt;



&lt;p&gt;Now that you know Betty, how do you use Betty?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I'm assuming you already have Betty installed. If you don't, checkout the installation guide &lt;a href="https://www.youtube.com/watch?v=7Oy5xw8FJO8"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  How to &lt;strong&gt;summon&lt;/strong&gt; Betty
&lt;/h2&gt;

&lt;p&gt;The usage is basically just&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;betty FILE...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where &lt;code&gt;FILE...&lt;/code&gt; means 1 file or more.&lt;br&gt;
Once you run Betty like this, Betty would enter each file you specified and do a series of checks. Here is a list of the things Betty checks for&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Indentation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Length of each line&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Placement of braces &lt;code&gt;{}&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Placement of spaces&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Naming of variables, functions, structs...&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Length of functions 🤨&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Commenting&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Macros &amp;amp; Enums&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Header files&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can find exhaustive information on Holberton-style code &lt;a href="https://github.com/holbertonschool/Betty/wiki"&gt;here&lt;/a&gt;, so you don't fall a victim of Betty as I did 😂😭&lt;/p&gt;

</description>
      <category>c</category>
      <category>linter</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
