From the course: C: Data Structures, Pointers, and File Systems
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Working with character conversions - C Tutorial
From the course: C: Data Structures, Pointers, and File Systems
Working with character conversions
- [Instructor] Most of the C type functions test for certain character types, such as uppercase, digits, spaces, and so on. These are the IS functions. A second set of C type functions is also available, those that modify characters. These aren't as numerous as the IS type functions, but they're quite handy. For example, the tolower function converts an uppercase letter to its lowercase counterpart. The toupper function does the opposite. Both functions take an integer as an argument and they return the modified character value as an integer. In this code I have a string defined at Line Six. It contains a mix of upper and lowercase text. The while loop at Line 10 walks through each character in the string, assigning it to integer variable CH. When the value of variable CH is equal to the null character, the loop stops. At Line 12, the putchar function outputs each character as modified by the tolower function. This function changes only uppercase letters A to Z. The value returned is…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Using single character I/O4m 4s
-
Testing characters2m 34s
-
Working with character conversions2m 17s
-
Understanding strings in C3m 3s
-
Fetching string input3m 18s
-
Sending string output2m 46s
-
Reviewing printf() placeholders3m 8s
-
Using printf() placeholders3m 36s
-
Exploring string functions3m 29s
-
Manipulating strings3m 53s
-
Avoiding string problems2m 27s
-
Challenge: String I/O and manipulation1m 46s
-
Solution: String I/O and manipulation2m 16s
-
-
-
-
-