Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

My question: when I try to run the program I get an error, the error says Unable

ID: 3560112 • Letter: M

Question

My question: when I try to run the program I get an error, the error says Unable to start program CUsersOwnerDesktopConsoleApplication1DebugConsoleApplication1.exe the system cannot find the file specified

My Code: (and srry i dont know how to post it in the Insert code block feture) but you can copy and paste it into visual studios (thats what i use)

#include <iostream>
#include <iomanip>
#include <conio.h>   
#include <string>   
using namespace std;


#include "ConsoleUtils.h"   


const int SIZEY(6);   
const int SIZEX(10);

const char MOUSE('@');
const char TUNNEL(' ');
const char WALL('#');

const int UP(72);
const int DOWN(80);
const int RIGHT(77);   
const int LEFT(75);

const char QUIT('Q');   

struct Item {
   int x, y;
   const char symbol;
};

int main()
{
  
   void initialiseGame(char g[][SIZEX + 1], char m[][SIZEX + 1], Item& mouse);
   void paintGame(const char g[][SIZEX + 1], string& mess);
   bool wantsToQuit(int key);
   bool isArrowKey(int k);
   int getKeyPress();
   void moveMouse(const char g[][SIZEX + 1], Item& mouse, int key, string& mess);
   void updateGrid(char g[][SIZEX + 1], const char m[][SIZEX + 1], Item mouse);
   void endProgram();

  
   char grid[SIZEY + 1][SIZEX + 1];   
   char maze[SIZEY + 1][SIZEX + 1];   
   Item mouse = { (SIZEX / 2) + 1, (SIZEY / 2) + 1, MOUSE };
   string message("LET'S START...");   

  
   Clrscr();
   initialiseGame(grid, maze, mouse);   
   paintGame(grid, message);   
   int key(getKeyPress());
   while (!wantsToQuit(key))
   {
       if (isArrowKey(key))
       {
           int dx(0), dy(0);
           moveMouse(grid, mouse, key, message);
           updateGrid(grid, maze, mouse);
       }
       else
           message = "INVALID KEY!";   
       paintGame(grid, message);
       key = getKeyPress();
   }
   endProgram();   
   return 0;
}

void initialiseGame(char grid[][SIZEX + 1], char maze[][SIZEX + 1], Item& mouse)
{
   void setInitialMazeStructure(char g[][SIZEX + 1]);
   void setInitialMouseCoordinates(Item& mouse);
   void updateGrid(char g[][SIZEX + 1], const char m[][SIZEX + 1], Item mouse);

   setInitialMazeStructure(maze);   
   setInitialMouseCoordinates(mouse);   
   updateGrid(grid, maze, mouse);
}

void setInitialMazeStructure(char maze[][SIZEX + 1])

{
  

   char initialMaze[SIZEY + 1][SIZEX + 1]

       = { { '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*' },
       { '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*' },
       { '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*' },
       { '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*' },
       { '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*' },
       { '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*' },
       { '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*' } };

   for (int row(1); row <= SIZEY; ++row)   
       for (int col(1); col <= SIZEX; ++col)   
           maze[row][col] = initialMaze[row][col];
}

void setInitialMouseCoordinates(Item& mouse)
{
   mouse.y = 3;
   mouse.x = 5;
}

void updateGrid(char grid[][SIZEX + 1], const char maze[][SIZEX + 1], Item mouse)
{
   void setMaze(char g[][SIZEX + 1], const char m[][SIZEX + 1]);
   void placeMouse(char g[][SIZEX + 1], Item mouse);

   setMaze(grid, maze);   
   placeMouse(grid, mouse);
}

void setMaze(char grid[][SIZEX + 1], const char maze[][SIZEX + 1])
{
   for (int row(1); row <= SIZEY; ++row)   
       for (int col(1); col <= SIZEX; ++col)
           grid[row][col] = maze[row][col];
}

void placeMouse(char g[][SIZEX + 1], Item m)
{
   g[m.y][m.x] = m.symbol;
}
void moveMouse(const char g[][SIZEX + 1], Item& m, int key, string& mess)
{
   void setKeyDirection(int k, int& dx, int& dy);
  
   int dx(0), dy(0);
   setKeyDirection(key, dx, dy);
  
   switch (g[m.y + dy][m.x + dx])
   {   
   case TUNNEL:
       m.y += dy;   
       m.x += dx;
       break;

   case WALL:   
       cout << '';
       mess = "CANNOT GO THERE!";
       break;
   }
}

void setKeyDirection(int key, int& dx, int& dy)
{
   switch (key)   
   {
   case LEFT:   
       dx = -1;
       dy = 0;
       break;
   case RIGHT:
       dx = +1;   
       dy = 0;
       break;
   case UP:
       dx = 0;
       dy = -1;   
       break;
   case DOWN:   
       dx = 0;
       dy = +1;   
       break;
   }
}

int getKeyPress()
{
   int keyPressed;
   keyPressed = getch();
   while (keyPressed == 224)
       keyPressed = getch();
   return(toupper(keyPressed));   
}

bool isArrowKey(int key)
{   
   return ((key == LEFT) || (key == RIGHT) || (key == UP) || (key == DOWN));
}
bool wantsToQuit(int key)
{   
   return (toupper(key) == QUIT);
}

void paintGame(const char gd[][SIZEX + 1], string& mess)
{
   void paintGrid(const char g[][SIZEX + 1]);

  
   Clrscr();

  
   SelectTextColour(clYellow);
   Gotoxy(0, 0);
   cout << "___MOUSE AND APPLES GAME___ " << endl;
   SelectBackColour(clWhite);
   SelectTextColour(clRed);
   Gotoxy(40, 0);
   cout << "Pascale Vacher: March 14";

  
   paintGrid(gd);

  
   SelectBackColour(clRed);
   SelectTextColour(clYellow);
   Gotoxy(40, 3);
   cout << "TO MOVE USE KEYBOARD ARROWS ";
   Gotoxy(40, 4);
   cout << "TO QUIT ENTER 'Q' ";

  
   SelectBackColour(clBlack);
   SelectTextColour(clWhite);
   Gotoxy(40, 8);
   cout << mess;   
   mess = "";
}

void paintGrid(const char g[][SIZEX + 1])
{
  
   SelectBackColour(clBlack);
   SelectTextColour(clWhite);
   Gotoxy(0, 2);
   for (int row(1); row <= SIZEY; ++row)
   {
       for (int col(1); col <= SIZEX; ++col)   
           cout << g[row][col];   
       cout << endl;
   }
}

void endProgram()
{
   SelectBackColour(clRed);
   SelectTextColour(clYellow);
   Gotoxy(40, 8);
  
   cout << " ";
   system("pause");
}

Explanation / Answer

There may not be any error in the code.

But you may try following and see if this solves the problem:

1) Using the repair tool in the VS Management to fix.

(I.e. right click Visual Studio 2010 and select Change/Remove from the Uninstall Programs tool in the Windows Control Panel, and click Repair in the Visual Studio Management window when it loads.)

OR

2) Remove the .suo; .ncb; and user project file, then restart the solution and it may fix the problem.

OR

3)set the project properties->web->start action->"don't open a page. wait for a request from an external application.