Help about my first program

Im using a book C++ for 21 day and im having troubles about my first program.

1
2
3
4
5
6
7
8
  #include <iostream>

 
 int main();
 {
   cout << "Zdravo svete!\n" ;
      return 0;
}


Im getting this error:
5 C:\Dev-Cpp\main.cpp expected unqualified-id before '{' token
5 C:\Dev-Cpp\main.cpp expected `,' or `;' before '{' token
C:\Dev-Cpp\Makefile.win [Build Error] [main.o] Error 1

Help me please if you can.Thanks!
You have an extra semicolon after int main() that shouldn't be there.
Delete that and your code should compile.

Also, Dev-C++ is really outdated (it was last updated in...2005, I believe?).
I would recommend getting the Orwell Dev-C++ version (http://orwelldevcpp.blogspot.com/ ) (which also includes a more up-to-date compiler) or find a different IDE.
You would also have to do one of two things.

Include this code here

using namespace std;

or make the cout line look like this

 
std::cout <<"Zdrava svete!\n";


Here would be a working example of both ways to do it.

1
2
3
4
5
6
7
8
9
 #include <iostream>

using namespace std;
 
 int main()
{
  cout << "Zdravo svete!\n" ;
  return 0;
}


1
2
3
4
5
6
7
 #include <iostream>

 int main()
{
  std::cout << "Zdravo svete!\n" ;
  return 0;
}

Topic archived. No new replies allowed.