From the course: Secure Coding in C
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Challenge: The secret code - C Tutorial
From the course: Secure Coding in C
Challenge: The secret code
(upbeat music) - [Instructor] Your challenge is to update a user's secret code. Do so in the following steps. Prompt the user to input their secret code. Then confirm that the input is valid. For example, using the fgets function, which I recommend, check for null input, and remove the new line. Test to verify that the code input is exactly five characters long. Once you have valid input, create a new code by appending the word "new" to the existing string, output the updated string showing it to the user, and always practice. During the entire process, practice your safe coding with strings for all of these steps. This challenge should take you about 15 minutes to complete.
Contents
-
-
-
-
-
-
Allocating strings3m 25s
-
(Locked)
Avoiding bad string assignment1m 33s
-
(Locked)
Working with string literals2m 17s
-
(Locked)
Minding string functions3m 21s
-
(Locked)
Storing passwords and codes1m 39s
-
(Locked)
Clearing data after use1m 52s
-
(Locked)
Challenge: The secret code52s
-
(Locked)
Solution: The secret code3m 14s
-
-
-