Some assistance for a newbie doing it from a book please

I am just starting out on the path to C++ and have got a book called C++ through game programming third edition. I cannot get past the very first topic as things just do not work.

I do not want this to spoilt my patch to C++ but it really is not a good start so help is most appreciated.

I am using MS Visual C++ Express and note pad.

I have followed the how to make game over but when I create the notepad bat file and run it I get an error.

the notepad file is:
game_over.exe
pause

The console window returns an error

game_over.exe is not recognized as an internal or external command,operable programme or batch file
1
2
3
4
5
6
7
8
9
10
  // Game Over
// A first C++ program

#include <iostream>

int main()
{
	cout << "Game Over!"
	return 0;
}
The program is probably listed as:
1
2
3
4
5
6
7
8
9
10
11
12
// Game Over
// A first C++ program

#include <iostream>

using namespace std;

int main()
{
	cout << "Game Over!"
	return 0;
}
The operating system probably doesn't know where to find game_over.exe.
Try specifying the full path to the .exe in the .bat file.
Hi chazzarilla,

I am in exactly the same place as you. Just started and programs straight out of the book don't work. There appears to be a degree of knowledge required even for the "beginners" programs.

I am using Dev-C++ version 4.9.9.2

I copied in the program from the tutorial in this website (C++);

// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World!";
return 0;
}

and it will not compile, there appears to be a problem with the line;
using namespace std;

I tried googling this but the explanation aren't any help, they all dive in too deep.

Is there a better tutorial for beginners somewhere ?
Thanks for the help.

I tried changing the Code and adding the new line:

// Game Over
// A first C++ program

#include <iostream>

using namespace std;


int main()
{
cout << "Game Over!"
return 0;
}

This did not help.

I then tried changing the file path to:

C:\Users\Darron\Desktop\C++ stuff\game_over.exe
pause

Which did not work either.

When I open the file in C++, the name which appears at the top is "game_over.cpp" Does this make a difference in how the computer finds the program, or is it always .exe
@quint22cp
Are you saying this does not compile in Dev-C++ version 4.9.9.2 ?
It ought to. What error message does it give?

By the way, the latest Dev-C++ is version 5.4.2 - you should get rid of the old version which I think dates back to about 2005 (ancient in C++ compiler terms).
http://orwelldevcpp.blogspot.com/

Hello Chervil,

These are the 3 lines from the debug;

\Dev-Cpp\print.c C:\Dev-Cpp\C iostream: No such file or directory.
C:\Dev-Cpp\print.c In function `main':
7 C:\Dev-Cpp\print.c syntax error before ':' token

thanks for the v5.4.2 info' I will try that.

Best Regards

@chazzarilla "game_over.cpp" is the name of the source code file, the actual text which you type in.

After it is compiled, an executable program with a name ending in .exe will be created. But it may not be in the same folder/directory as the source, it could be in some sub-directory.
@ quint22cp The problem is you named your file with a .c extension: print.c
That makes the compiler think you want to compile this as C, not C++
Change it to print.cpp
The cpp means C++ and it should now compile successfully.
Thanks Chervil, that works now. I had to add system("pause");
to stop the window closing so I could see the output.

The problem I think I'm experiencing is I don't know which are C errors and which are compiler errors.
The problem I think I'm experiencing is I don't know which are C errors and which are compiler errors.

I'm not sure what you mean by that.

If you build your application, and it fails to compile, then the errors you get are compiler errors.

If you build your application, and it compiles but fails to link, then the errors you get are linker errors.

If you build your application and it succeeds, but when you run it you get errors, then those are run-time errors.
Topic archived. No new replies allowed.