C Programming Tutorial 25 - Char Data Type

submitted by mkenny400 on 03/19/18 1

We can create a char variable like this:   char var = 'A';   It is very important that we use single quotes.   That's really all there is to creating a char variable, so now let's talk printing this to the console and getting it from user input.   We are going to need to learn a new format character, specifically %c. This tells the function that we are going to be working with char data.   printf("%c\n", var);   Now, if we actually wanted to scan the data from the console, we can use scanf():   scanf("%c", &var);   If you want to know more about ASCII, check out www.asciitable.com/   The first section on the ASCII table are called control characters and only a few are going to be useful to us. I'd also group the last one in here, which is the DEL ASCII code. These codes were for controlling devices, such as printers. Some are still going to be useful to us, such as the new line character. The rest of the standard table are called printable characters. These are the characters that you can visually see. You can also see that each character has an associated integer value, 0-127.   The second table represents the extended ASCII, which gives more available options.   In the next video we are going to create a program that will convert between int and ASCII. By the end of that video, you'll see how easy working with ASCII is. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Support me! www.patreon.com/calebcurry Subscribe to my newsletter: eepurl.com/-8qtH Donate!: bit.ly/DonateCTVM2. ~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~ More content: CalebCurry.com Facebook: www.facebook.com/CalebTheVideoMaker Google+: plus.google.com/+CalebTheVideoMaker2 Twitter: twitter.com/calebCurry Amazing Web Hosting - www.dreamhost.com/r.cgi?1487063 (The best web hosting for a cheap price!)

Leave a comment

Be the first to comment

Collections with this video
Email
Message
×
Embed video on a website or blog
Width
px
Height
px
×
Join Huzzaz
Start collecting all your favorite videos
×
Log in
Join Huzzaz

facebook login
×
Retrieve username and password
Name
Enter your email address to retrieve your username and password
(Check your spam folder if you don't find it in your inbox)

×