From the course: Code Clinic: C
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.