<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sams Personal Site</title><link>https://alpha.samuelv.dev/school-notes/cop2220c/</link><description>Recent content on Sams Personal Site</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 27 Mar 2026 13:42:39 -0400</lastBuildDate><atom:link href="https://alpha.samuelv.dev/school-notes/cop2220c/index.xml" rel="self" type="application/rss+xml"/><item><title>COP2220C | Structures, Memory, and IO</title><link>https://alpha.samuelv.dev/school-notes/cop2220c/exam3/</link><pubDate>Fri, 27 Mar 2026 13:42:39 -0400</pubDate><guid>https://alpha.samuelv.dev/school-notes/cop2220c/exam3/</guid><description>&lt;h2 id="typedef-uses"&gt;Typedef uses&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;It is a simple substitution of an existing data type for a new one&lt;/li&gt;
&lt;li&gt;Effectively it is a new name for the same data&lt;/li&gt;
&lt;li&gt;One common use is creating data types that are more descriptive:&lt;/li&gt;
&lt;li&gt;typedef unsigned char uint8;&lt;/li&gt;
&lt;li&gt;typedef unsigned int uint32;&lt;/li&gt;
&lt;li&gt;Now variable bit sizes are easily seen&lt;/li&gt;
&lt;li&gt;Also has uses when writing code that may run on different processors and platforms.&lt;/li&gt;
&lt;li&gt;What if we wanted to create a more advanced data type?&lt;/li&gt;
&lt;li&gt;Something that could organize several bytes into something new.&lt;/li&gt;
&lt;li&gt;Something more than a simple substitution….&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="structs"&gt;Structs&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Structs are used primarily for organization of data types.&lt;/li&gt;
&lt;li&gt;Say we are tracking someone’s birthday.&lt;/li&gt;
&lt;li&gt;int year, month, day;&lt;/li&gt;
&lt;li&gt;However those three variables can be considered as one, a date.&lt;/li&gt;
&lt;li&gt;We can create a new data type to hold all of this data and keep it organized.&lt;/li&gt;
&lt;li&gt;Should be created in a logical manner, the variables within the new data type are a piece of it.&lt;/li&gt;
&lt;li&gt;What may be the components to a data type BankCustomer?&lt;/li&gt;
&lt;li&gt;Name&lt;/li&gt;
&lt;li&gt;Account Number&lt;/li&gt;
&lt;li&gt;Balance&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="creating-structs-part-1"&gt;Creating Structs Part 1&lt;/h2&gt;
&lt;p&gt;First method:&lt;/p&gt;</description></item><item><title>COP2220C | Algorithms, Pointers, and Scope</title><link>https://alpha.samuelv.dev/school-notes/cop2220c/exam2/</link><pubDate>Wed, 25 Mar 2026 13:42:39 -0400</pubDate><guid>https://alpha.samuelv.dev/school-notes/cop2220c/exam2/</guid><description>&lt;hr&gt;
&lt;h2 id="modular-programming"&gt;Modular Programming&lt;/h2&gt;
&lt;p&gt;The problem is broken down into multiple levels and these levels serve to abstract the problem making it simpler.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Top Down Design:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Starts from the top then you break pieces down.
&lt;img src="https://alpha.samuelv.dev/cop2220C/20260302221722.png" alt="top-down-design"&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Bottom Up Design:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Employs is very similar just instead it works with the main level being at the bottom and the broken down pieces being on the top. Basically if you took the image above flipped it 180 deg.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="function-declaration"&gt;Function declaration&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Functions have a data type that they return which is regarded as the function output.&lt;/li&gt;
&lt;li&gt;Functions have names which are used to reference them. Like in function calls.&lt;/li&gt;
&lt;li&gt;Functions have parameters which are the inputs for your function. They share the same format with variables &lt;code&gt;myfunc(var-type name)&lt;/code&gt; so like &lt;code&gt;void myFunc(int x)&lt;/code&gt; is an example.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="declaration-vs-definition"&gt;Declaration vs definition&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;When declaring a function you are specifying the return type, identifier, and parameters without the method body. In other words its just an outline of the function.
&lt;ul&gt;
&lt;li&gt;Method declarations are used to tell C that a method exists and the actual method body imported from another c file.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;A definition performs the same steps as a declaration specifying the return type, identifier, and parameters just with the method body as well.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="function-parameters"&gt;Function parameters&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Remember that the parameters are local variables because their scope does not exist outside the method itself.&lt;/li&gt;
&lt;li&gt;Remember that parameters are copies of the passed variable. If you want to edit a variable directly a point is required.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="function-activity"&gt;Function activity&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;When you call a function it will copy the values of the parameters and then it executes the code in the method body. When all the code has executed the local variables are destroyed (memory release)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="scope"&gt;Scope&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;When a variable is declared memory is allocated and the memory is associated with the variables name.&lt;/li&gt;
&lt;li&gt;The compiler works with maximum efficiency so any scope that is not used later gets discarded.&lt;/li&gt;
&lt;li&gt;When the variable has been released the compiler will no longer recognize the variable.&lt;/li&gt;
&lt;li&gt;Note: its good practice to keep variables at the lowest scope possible (its released as soon as possible)&lt;/li&gt;
&lt;li&gt;If scope is ignored its possible that another could be accessed instead of the desired one.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="global-variables"&gt;Global Variables&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;It is possible to declare a variable such that it is available throughout your program.&lt;/li&gt;
&lt;li&gt;This allows a variable to carry information throughout your program.&lt;/li&gt;
&lt;li&gt;Global variables should be used as infrequently as possible.&lt;/li&gt;
&lt;li&gt;Too many global variables bogs down what the compiler has to maintain.&lt;/li&gt;
&lt;li&gt;Also makes your code harder to read.&lt;/li&gt;
&lt;li&gt;Still, they have their place and can be powerful to use.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="https://alpha.samuelv.dev/cop2220C/20260303003248.png" alt="variable-scope"&gt;&lt;/p&gt;</description></item><item><title>COP2220C | Variables, Characters, and Logic</title><link>https://alpha.samuelv.dev/school-notes/cop2220c/exam1/</link><pubDate>Tue, 24 Mar 2026 13:42:39 -0400</pubDate><guid>https://alpha.samuelv.dev/school-notes/cop2220c/exam1/</guid><description>&lt;p&gt;&lt;strong&gt;Terms to know:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Syntax – Rules for writing a program in a particular language.&lt;/li&gt;
&lt;li&gt;Operator – Symbol representing a function that calculates a value.&lt;/li&gt;
&lt;li&gt;Operand – Value to the left or right of an operator.&lt;/li&gt;
&lt;li&gt;Promotion – Changing the data type of a variable so that it can hold more information.&lt;/li&gt;
&lt;li&gt;Demotion – Changing the data type of a variable so that it loses information.&lt;/li&gt;
&lt;li&gt;Type Casting – A way to temporarily and explicitly change the data type of a variable.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;How C code compiles:
User written code -&amp;gt; &lt;a href="http://en.wikipedia.org/wiki/Object_file"&gt;Object file&lt;/a&gt; (processor specific) -&amp;gt; Linker Compiles code -&amp;gt; Machine code (executable)
&lt;img src="https://alpha.samuelv.dev/cop2220C/20260204013613.png" alt="Compilation"&gt;&lt;/p&gt;</description></item></channel></rss>