Hi I'm using dev-c++ for the first time while trying to learn the very basics of programming in C++.
I tried the code below which everyone in the coding world has seen. I can't get it to work. But I got others to work. I tried many different ways but can you help me with the correct way to enter the code.
Thanks,
using namespace std;
int main(int argc, char *argv[])
{
cout "Hello World!";
system("PAUSE");
return 0;
}
For starters, throw out Dev-C++ and get a different IDE. Dev-C++ is ancient and outdated, and lots of valid code will not compile in it.
If you like the look and feel of Dev-C++, get wxDev-C++. It's a more modern version and feels pretty much the same (or so I hear, I haven't used it myself).
As for your code
1 2 3 4 5 6 7 8 9 10
#include <iostream> // for cout, you need to #include the iostream header
#include <cstdlib> // for system, you need to #include the cstdlib header
usingnamespace std;
int main(int argc, char *argv[])
{
cout << "Hello World!"; // you need the << operator to send things to cout
system("PAUSE"); // some people will give you grief for using system
return 0;
}
You don't actually need "#include<cstdlib>" to use "system()". And yeah you don't need anything in the parentheses in front of int main. And since main() doesn't actually respond to anything else, (because it's the whole function), you can leave out the returning part. So that'll shorten it to...