C Programming Tutorial 19 – Intro to Data Types – Part 1

This video is going to introduce the concept of data types. First, let’s define data. Data is any piece of information. Think of a variable. Let’s say we have a variable called tacos, and the value of this variable is 5. The 5 is a piece of data (datum). Now, each piece of data has an associated data type.

A data type is defines how the computer should treat a certain value.

As we learned before, integer division is completely different than double division.
5/2 = 2, but 5.0/2 = 2.5.

We can group data types into groups that help us understand what they are. The first grouping I would say is called primitive data types. These data types can be considered the building blocks. They cannot be broken down further into new data types.

Inside of the primitive data types we have numeric (number) data types, a char data type, and a _Bool data type. Numeric data types are used to store numbers, the char data type is used to store a single character, such as “;” or ” “, and the _Bool data type is used to store data in one of two states. These values usually represent true or false, on or off, high or low, yes or no… anything that is binary (two states).

The primitive data types are foundational to C programming, but once we get into things you are probably going to want to build more complex data types.

So the second category is complex data types. That is where structs come in. A struct allows you to define your very own data type. This means that we could make a more complex data type such as date.

Now, when we can actually create a variable that stores a date. So we could do something like:

date today;

similar to how we can do:

int x;

We can take all of these puzzle pieces and build things up to more complex things. For example, we can combine multiple structs to make a struct containing structs! A common application of this is a linked list.

So starting off the data types are pretty simple, but once we get into things we can make some very cool stuff with some custom data structures.

Some languages have what are known as objects, which are very similar to structs, but C does not have object oriented programming, so you don’t even have to worry about that. Learn structs well and they will help you understand objects when you learn other languages like C++ or objective C.


Support me! http://www.patreon.com/calebcurry

Subscribe to my newsletter: http://eepurl.com/-8qtH

Donate!: http://bit.ly/DonateCTVM2.

~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~

More content: http://CalebCurry.com
Facebook: http://www.facebook.com/CalebTheVideoMaker
Google+: https://plus.google.com/+CalebTheVideoMaker2
Twitter: http://twitter.com/calebCurry

Amazing Web Hosting – https://www.dreamhost.com/r.cgi?1487063 (The best web hosting for a cheap price!)


Ned Martinez-Zavala says:

Awesome! Will you be going over pointers?

Michael Taylor says:

Great tutorial, just be careful with the use of the word ‘atomic’ – which by your definition is derived from primitive types which is incorrect depending on the environment and operations being done.

Atomic is used when dealing with race condition environments (multi-threaded usually) when you do read -> evaluate -> update -> sync to disk for example. You would want operations around the critical piece of code atomic to prevent values in the cpu register to be volatile to change between two operations (usually read – update – write structure).

TL;DR – Atomic operation means an operation that appears to be instantaneous from the perspective of all other threads. You don’t need to worry about a partly complete operation when the guarantee applies when using atomic processed.

five six says:

youre awesome dude hope your life is going well, congratulations on acquiring a job!

Torben Fischer says:

Dude, great stuff – get the simply stuff down, then the harder stuff will reveal itself.

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!