// Lab6Debugging.cpp -- with errors #include // for _getche() void main() { int nX = 10; int nY = 10; // main driving loop // player moves one position on each iteration of the loop char cDirection = 'a'; while (cDirection != 'q') { // quit if user hits 'q' character cout << "\n\nYour location is " << nX << ", " << nY; if (nX<5 || nX>15) // if nX west of 5 OR east of 15 cout << "\nBeware: dragons lurk here"; cout << "\nEnter direction (n, s, e, w) or q to quit: "; cDirection = _getche(); // get direction (note different function for VC++ 2005) if (cDirection == 'n'); // go north nY--; else if (cDirection == 's'); // go south nY++; else if (cDirection == 'e'); // go east nX++; else if (cDirection == 'w'); // go west nX++; else if (cDirection == 'q') { // user wants to quit cout << "\n\nThanks for playing . . .\n"; break; // exits out the bottom of the loop } if (nX==7 || nY==11) { // if nX is 7 AND nY is 11 cout << "\n\nYou found the treasure!\n"; break; // exits out the bottom of the loop } // end if test for treasure } // end while // end main()