using namespace std;
This is namespace pollution. Use this instead: using std::string; using std::cout; using std::cin; using std::endl; |
Sorry ?? What the hell are ya saying ??? Man if you read any C++ books I dont think you have seen any message like
DONT USE using namespace std; |
!! Even programmers recommand it for people to use it as you save A LOT OF TIME THAN writting every time
std::blah blah
!
What you have just said in useless. We dont need anymore the
std::cin
...
std::cout
.... !!!
On the other hand, you told him use
getch()
???? Oh My GOD !! If you want to grow as a programmer is the worst thing you can do. In all C++ contents and competitions in my country, using
getch()
or
clrscr();
or
system("pause");
or any other commands like this are BANNED! If you use them you lose all your points, so please stop ! What you said in beginning was ok ! He didnt need to use
windows.h
or
conio.h
. But this is all. Everything else is useless for a programmer.
snowboarder7, if you want console open until you press a key, (i dont know why u have to use a command. i dont use any command) just use this structure:
1 2 3 4 5 6 7 8 9 10
|
#include <iostream> // or <fstream> if you want to print to file
using namespace std;
int main()
{
...
//your code here
...
return 0; // This is only thing i use (p.s.: i am using MinGW Developer Studio and wxDev C++, and rarely i work in C# or Visual C++)
}
|
now ill give u an eg. with fstream
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <fstream>
using namespace std;
int main()
{
... //variables ...
ifstream in("text.in");
ofstream out("text.out");
... // now you will use the in, out instead of cin, cout ( you can put anything instead of in, out , for eg. : f("text.in"); g("text.out");
// when i tell you this i suppose you have already read and learned about file printing as im not going to write here a tutorial
return 0;
}
|