From the course: Secure Coding in C
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Challenge: Fix the code - C Tutorial
From the course: Secure Coding in C
Challenge: Fix the code
(upbeat music) - [Instructor] For this challenge, I present you with this code, which is included with the exercise files. The code compiles, and it runs. And I'll type some text. And it works. I'm also going to go ahead to a command prompt, where I can type the contents of that file just created, and there you see the contents. It works, yet, I have placed into this code eight issues. These are items mentioned in this course that should be addressed to make the code run safe, and in a predictable manner. Your task is to find and correct the issues placed into the exercise file. Modify the code as necessary, adding or removing statements, changing things to make them more safe, and remove any undefined behaviors. Keep working with the code until you find and correct as many of the eight issues as possible. This challenge should take you about 15 minutes to complete.
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
-
-
-
-
Formatting preprocessor directives1m 23s
-
(Locked)
Using an assignment as a condition1m 31s
-
(Locked)
Avoiding putchar() in a while loop1m 35s
-
(Locked)
Using the system() call1m 58s
-
(Locked)
Accessing elements beyond the array size2m 2s
-
(Locked)
Converting integers2m 26s
-
(Locked)
Looping with floating point values1m 39s
-
(Locked)
Using return values1m 58s
-
(Locked)
Confirming when EOF has been read2m 31s
-
(Locked)
Challenge: Fix the code1m 12s
-
(Locked)
Solution: Fix the code2m 12s
-
-
-
-
-