From the course: Debugging C Code

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Challenge: Find the bug

Challenge: Find the bug - C Tutorial

From the course: Debugging C Code

Start my 1-month free trial

Challenge: Find the bug

(upbeat music) - [Instructor] Here is source code for a program that extracts a file name from the end of a path name. Line 35 enlists six path names in an array. Now some have a file name at the end, and others don't. These strings are then passed to the file name function right here, which extracts only the file name, the last part after the separator and returns that value. Let's build and run and see what the code does. And as you can see, the output isn't really what I've intended. The filename isn't properly extracted with a leading separator here, and here. Further, these items should not be included as well. So the program, the code needs a little work. It's possible to fix this code without using a debugger. And that's how I originally did it. But your task is more specific. Paste code from the exercise file into a code blocks project created for debugging. Step through the file name function, to observe how…

Contents