From the course: Code Clinic: C

Unlock the full course today

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

Creating a 2D array solution

Creating a 2D array solution - C Tutorial

From the course: Code Clinic: C

Start my 1-month free trial

Creating a 2D array solution

- [Instructor] Despite success with the N Queens code, I wanted to try it again. Specifically I wanted to work on the recursive routine to ensure that I fully understood the diagonal attack. Because my stumbling block was the single dimension array I figured I would return back to a two dimensional character array. Unlike my first disastrous attempt to solve this problem, I would track only the queen's location and not her attack vectors. So this third solution was really a combination of both my previous attempts, with the emphasis on making a diagonal attack easier for me to code. A two dimensional character array is faked right here at line 62. I use a pointer instead of two dimensional array notation simply because this is the C language and pointers are a big deal. Of course, that also requires some pointer math, but for some reason my brain could handle that type of math better than the row column thing going on with the single dimension integer array as covered in the previous…

Contents