@HadMuffin
conio.h is not standard & not needed in this program. Just use
std::cin instead of
_getch(); there is a whole article about that in the documentation section.
I like to break bad habits early - so try this:
instead of line 4, put std:: before each STL thing, or specify a using statement for each STL thing:
1st example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
char a;
std::cout << "Hello World!" << std::endl;
_getch();
std::cin >> a;
return 0; // I am old fashioned so I always do this
}
|
2nd example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
char a;
cout << "Hello World!" << endl;
cin >> a;
return 0; // I am old fashioned so I always do this
}
|
The reason is that using the whole std namespace pollutes the global namespace (there are hundreds of things in std), causing conflicts in the naming of variables & functions - which is what namespaces is trying to avoid ! If you wrote a program that had distance, left, right, pair etc then you would have problems.
Some guys always use
std::
regardless, but it is possible to do a mixture of styles - specify individual using statements for things used a lot, then do
std::
for things you might not use as much like
std::find
say.
Hope all goes well :)