Error: "Cannot Find The File Specified"[solved]

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
fingerfry
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Tue Sep 01, 2009 6:31 pm
Favorite Gaming Platforms: Xbox 360, PC, Gameboy Advance SP
Location: Palm Desert, California
Contact:

Error: "Cannot Find The File Specified"[solved]

Post by fingerfry »

So I picked programming up again in the last few weeks, and I have a minor problem. It isn't anything crazy, but it is really annoying. I'm running Visual C++ 2008 Express on Vista, but every time I try to run a program it shows an error. I've been able to run some programs by fiddling with the file, but I don't remember what I did. The message that pops up when I run the program says:

"Unable to start program 'C:\Users\Cameron\Documents\Visual Studio
2008\Projects\mtytictac\Debug\mtytictac.exe'.

The system cannot find the file specified."


I spelled it "mtytictac" because i already have a couple of tic tac toe programs. I know the syntax is correct because I have run the program before under a different name. I used a working program so I would KNOW it wasn't the syntax. It has occurred to me that the problem is most likely a configuration setting, but I have no clue where to start. Any help from you guys would be widely appreciated :) Please help...

Thank you, and here is the source code

Code: Select all

 
//Tic Tac Toe
//enter a number and press enter to put your marker there
#include <iostream>

//establish the co-ordinates for the board
void main() {
	char cSquare1('1');
	char cSquare2('2');
	char cSquare3('3');
	char cSquare4('4');
	char cSquare5('5');
	char cSquare6('6');
	char cSquare7('7');
	char cSquare8('8');
	char cSquare9('9');
	int iPlayerTurn(1);
	bool bGameOver(true);

	// Draw the board and loop the game
	do {
		// Print board
		std::cout << cSquare1 << "|" << cSquare2 << "|" << cSquare3 << std::endl;
		std::cout << "-+-+-"<< std::endl;
		std::cout << cSquare4 << "|" << cSquare5 << "|" << cSquare6 << std::endl;
		std::cout << "-+-+-"<< std::endl;
		std::cout << cSquare7 << "|" << cSquare8 << "|" << cSquare9 << std::endl;

		// Set player marker: Player 1 uses X and Player 2 uses O
		char cPlayerMark;
		if (iPlayerTurn == 1) {
			cPlayerMark = 'X';
		} else {
			cPlayerMark = 'O';
		}
		
		// Prompt the player for a move
		std::cout << "Player" << iPlayerTurn << "'s move:" << std::endl;
		bool bValidMove;
		// Loop until we get a valid move
		do {
			char cNextMove;
			std::cin >> cNextMove;
			bValidMove = true;

			// Check for a valid move
			if (cNextMove == '1' && cSquare1 == '1') {
				cSquare1 = cPlayerMark;
			} else if (cNextMove == '2' && cSquare2 == '2') {
				cSquare2 = cPlayerMark;
			} else if (cNextMove == '3' && cSquare3 == '3') {
				cSquare3 = cPlayerMark;
			} else if (cNextMove == '4' && cSquare4 == '4') {
				cSquare4 = cPlayerMark;
			} else if (cNextMove == '5' && cSquare5 == '5') {
				cSquare5 = cPlayerMark;
			} else if (cNextMove == '6' && cSquare6 == '6') {
				cSquare6 = cPlayerMark;
			} else if (cNextMove == '7' && cSquare7 == '7') {
				cSquare7 = cPlayerMark;
			} else if (cNextMove == '8' && cSquare8 == '8') {
				cSquare8 = cPlayerMark;
			} else if (cNextMove == '9' && cSquare9 == '9') {
				cSquare9 = cPlayerMark;
			} else {
				std::cout << ("Cant you read? someone already moved there idiot! 
					"what do you have to say for yourself? You are a freaking idiot!.") << std::endl;
				bValidMove = false;
			}
		} while (!bValidMove);

		bGameOver		= false;
		bool bWinGame	= true;
		// Check for end of game conditions
		if (cSquare1 != '1') {
			if (cSquare2 == cSquare1 && cSquare3 == cSquare1) {
				bGameOver = true;
			}
			if (cSquare4 == cSquare1 && cSquare7 == cSquare1) {
				bGameOver = true;
			}
		}
		if (cSquare5 != '5') {
			if (cSquare1 == cSquare5 && cSquare9 == cSquare5) {
				bGameOver = true;
			}
			if (cSquare2 == cSquare5 && cSquare8 == cSquare5) {
				bGameOver = true;
			}
			if (cSquare4 == cSquare5 && cSquare6 == cSquare5) {
				bGameOver = true;
			}
			if (cSquare3 == cSquare5 && cSquare7 == cSquare5) {
				bGameOver = true;
			}
		}
		if (cSquare9 != '9') {
			if (cSquare3 == cSquare9 && cSquare6 == cSquare9) {
				bGameOver = true;
			}
			if (cSquare7 == cSquare9 && cSquare8 == cSquare9) {
				bGameOver = true;
			}
		}
		// Need to check the board full (no-win condition)
		if (cSquare1 != '1' && cSquare2 != '2' && cSquare3 != '3' &&
			cSquare4 != '4' && cSquare5 != '5' && cSquare6 != '6' &&
			cSquare7 != '7' && cSquare8 != '8' && cSquare9 != '9' && !bGameOver)
		{
			bGameOver = true;
			bWinGame = false;
		}

		if (bGameOver) {
			if (bWinGame) {
				std::cout << "Player" << iPlayerTurn << " wins!" << std::endl;
			}
			// Print ending board
			std::cout << cSquare1 << "|" << cSquare2 << "|" << cSquare3 << std::endl;
			std::cout << "-+-+-"<< std::endl;
			std::cout << cSquare4 << "|" << cSquare5 << "|" << cSquare6 << std::endl;
			std::cout << "-+-+-"<< std::endl;
			std::cout << cSquare7 << "|" << cSquare8 << "|" << cSquare9 << std::endl;

			std::cout << "Game Over!" << std::endl;
			std::cout << "Play again (y/n)?" << std::endl;
			char cPlayAgain;
			std::cin >> cPlayAgain;

			if (cPlayAgain == 'y') {
				bGameOver = false;
				// Clear the board
				cSquare1 = '1';
				cSquare2 = '2';
				cSquare3 = '3';
				cSquare4 = '4';
				cSquare5 = '5';
				cSquare6 = '6';
				cSquare7 = '7';
				cSquare8 = '8';
				cSquare9 = '9';
			}
			iPlayerTurn = 1;
		} else {
			// Alternate player turns
			if (iPlayerTurn == 1) {
				iPlayerTurn = 2;
			} else {
				iPlayerTurn = 1;
			}
		}
	} while (!bGameOver);
}
Last edited by fingerfry on Wed Sep 09, 2009 7:21 pm, edited 1 time in total.
Image
andrew
Chaos Rift Regular
Chaos Rift Regular
Posts: 121
Joined: Mon Dec 08, 2008 2:12 pm

Re: Error: "Cannot Find The File Specified"

Post by andrew »

It sounds like you haven't compiled it. If the file isn't there then the project hasn't been built.
fingerfry
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Tue Sep 01, 2009 6:31 pm
Favorite Gaming Platforms: Xbox 360, PC, Gameboy Advance SP
Location: Palm Desert, California
Contact:

Re: Error: "Cannot Find The File Specified"

Post by fingerfry »

Nah, I've compiled it. I went into the build tab and clicked "Build a solution" but it still will not run.

And I have used the "Start Without Debugging"(Ctrl-f5) option as well.
Last edited by fingerfry on Sat Sep 05, 2009 6:41 pm, edited 1 time in total.
Image
fingerfry
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Tue Sep 01, 2009 6:31 pm
Favorite Gaming Platforms: Xbox 360, PC, Gameboy Advance SP
Location: Palm Desert, California
Contact:

Re: Error: "Cannot Find The File Specified"

Post by fingerfry »

Also; if I go into the location that is mentioned, I can see the main.cpp right there.
Image
andrew
Chaos Rift Regular
Chaos Rift Regular
Posts: 121
Joined: Mon Dec 08, 2008 2:12 pm

Re: Error: "Cannot Find The File Specified"

Post by andrew »

Have you tried a simple "hello world" program to verify that everything is working?

EDIT:
I think you left out some information:

Code: Select all

------ Build started: Project: ttt, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\documents and settings\administrator\my documents\visual studio 2008\projects\ttt\ttt\main.cpp(66) : error C2001: newline in constant
Build log was saved at "file://c:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\ttt\ttt\Debug\BuildLog.htm"
ttt - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Did you get an error message similar to this one that you somehow missed?

EDIT2:
Change this:

Code: Select all

std::cout << ("Cant you read? someone already moved there idiot!
               "what do you have to say for yourself? You are a freaking idiot!." << std::endl;
to this:

Code: Select all

std::cout << "Cant you read? someone already moved there idiot! " <<
               "what do you have to say for yourself? You are a freaking idiot!.") << std::endl;
Last edited by andrew on Sat Sep 05, 2009 6:57 pm, edited 1 time in total.
fingerfry
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Tue Sep 01, 2009 6:31 pm
Favorite Gaming Platforms: Xbox 360, PC, Gameboy Advance SP
Location: Palm Desert, California
Contact:

Re: Error: "Cannot Find The File Specified"

Post by fingerfry »

Yes, I have. I can run programs after 30+ minutes of messing around with the file, but I can never remember exactly what I did. I want to be able to run the program without having to waste time.
Image
fingerfry
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Tue Sep 01, 2009 6:31 pm
Favorite Gaming Platforms: Xbox 360, PC, Gameboy Advance SP
Location: Palm Desert, California
Contact:

Re: Error: "Cannot Find The File Specified"

Post by fingerfry »

This is how the build looks:

Code: Select all

 1>------ Build started: Project: mtytictac, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>c1xx : fatal error C1083: Cannot open source file: '.\main.cpp': No such file or directory
1>Build log was saved at "file://c:\Users\Cameron\Documents\Visual Studio 2008\Projects\mtytictac\mtytictac\Debug\BuildLog.htm"
1>mtytictac - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

This is where the error is :

Code: Select all

 1>c1xx : fatal error C1083: Cannot open source file: '.\main.cpp': No such file or directory
Last edited by fingerfry on Sat Sep 05, 2009 7:02 pm, edited 1 time in total.
Image
fingerfry
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Tue Sep 01, 2009 6:31 pm
Favorite Gaming Platforms: Xbox 360, PC, Gameboy Advance SP
Location: Palm Desert, California
Contact:

Re: Error: "Cannot Find The File Specified"

Post by fingerfry »

I changed the line to what you suggested, but I get the same error. Good point though, that was poor programming syntax on my part(it still worked though :) ).
Image
andrew
Chaos Rift Regular
Chaos Rift Regular
Posts: 121
Joined: Mon Dec 08, 2008 2:12 pm

Re: Error: "Cannot Find The File Specified"

Post by andrew »

This should help you. After a while you won't have to think about how to do it. ;)
fingerfry
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Tue Sep 01, 2009 6:31 pm
Favorite Gaming Platforms: Xbox 360, PC, Gameboy Advance SP
Location: Palm Desert, California
Contact:

Re: Error: "Cannot Find The File Specified"

Post by fingerfry »

Yeah..... About that link... :roll:

I did all of that, and I still get Bill's middle finger(stupid error message). :(
Image
andrew
Chaos Rift Regular
Chaos Rift Regular
Posts: 121
Joined: Mon Dec 08, 2008 2:12 pm

Re: Error: "Cannot Find The File Specified"

Post by andrew »

If you do it exactly like it is done in this video and it still doesn't work, something is wrong with Visual Studio and you might want to reinstall it or something. Otherwise, you might give Code::Blocks a try.
fingerfry
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Tue Sep 01, 2009 6:31 pm
Favorite Gaming Platforms: Xbox 360, PC, Gameboy Advance SP
Location: Palm Desert, California
Contact:

Re: Error: "Cannot Find The File Specified"

Post by fingerfry »

andrew wrote:If you do it exactly like it is done in this video and it still doesn't work, something is wrong with Visual Studio and you might want to reinstall it or something. Otherwise, you might give Code::Blocks a try.
I guess I'll try to re-install. If that is to no avail, then I'm Going to be a Code Blocks guy 8-)
Thanks for all your help.
Image
andrew
Chaos Rift Regular
Chaos Rift Regular
Posts: 121
Joined: Mon Dec 08, 2008 2:12 pm

Re: Error: "Cannot Find The File Specified"

Post by andrew »

fingerfry wrote:I guess I'll try to re-install. If that is to no avail, then I'm Going to be a Code Blocks guy 8-)
Thanks for all your help.
Let us know how it goes. :)
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Error: "Cannot Find The File Specified"

Post by MarauderIIC »

Try running visual studio as administrator, just for grins.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
fingerfry
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Tue Sep 01, 2009 6:31 pm
Favorite Gaming Platforms: Xbox 360, PC, Gameboy Advance SP
Location: Palm Desert, California
Contact:

Re: Error: "Cannot Find The File Specified"

Post by fingerfry »

It works after I re-installed it. I have no idea what was wrong with it, but it is fine now :)
Image
Post Reply