very very new

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

using namespace 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;
}
// some people will give you grief for using system


I'll do it :) Please don't use system.
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...

1
2
3
4
5
6
7
#include <iostream>
using namespace std;
int main()
{
  cout << "Hello World!";
  system("PAUSE");
}
Last edited on
You don't actually need "#include<cstdlib>" to use "system()".


Unless your C++ implementation complies with the C++ definition, that is. Then you will. For example, in this case: http://ideone.com/DdgHV

And since main() doesn't actually respond to anything else,


It returns a value to the caller of the program.
Last edited on
Topic archived. No new replies allowed.