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;
}
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 ?
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/
\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
@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.