From the course: Debugging C Code

Unlock the full course today

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

Solution: Find the bug

Solution: Find the bug - C Tutorial

From the course: Debugging C Code

Start my 1-month free trial

Solution: Find the bug

(upbeat music) - [Instructor] I've built a debug project around the exercise valve provided for this challenge, and here it is running. Where I've set a break point, at line 17, and had run to that location. You see windows from my watches, and the memory dump, showing where the strings are stored in memory. So I'll go ahead and step through this, and we'll see what happens. Pointer P is initialized, it's pointing or referencing the end of the string. Now as I click the next line button and step through the loop, you'll see pointer P as it backs up through the string, to try to find out where that file name starts, specifically the separator character there. And the loop should end, but you see, Pointer P still references this separator. This is where the problem happens. I'll exit the debugger. Now my guess is that I need to increment pointer P here at line 25, after the loop. So I'll go ahead and add that…

Contents