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.

Failing for the first time

Failing for the first time - C Tutorial

From the course: Code Clinic: C

Start my 1-month free trial

Failing for the first time

- [Instructor] I've looked at Eight Queens code before. I can understand what's going on, but the code always seemed so cryptic, and it wasn't just single-letter variable names that bothered me. It was trying to decipher exactly how the code worked. Yes, that's one of the shortcomings of the C language. So I began my Eight Queens adventure by creating code that operated on a character array, rows and columns. First, to avoid the logic that comprises the bulk of the code, I worked on the main function, which examines the command line arguments. So the default of eight squares is set when no arguments are specified, and if the first argument is a value, then that value is converted into an integer, otherwise the help message is displayed. Then, options for brief and board are checked, and the output mode variable is set accordingly. I also wrote the show board function, which displays the board in brief output I didn't even bother to code the brief output. For this first approach I just…

Contents