Author Topic: Hello World Fail  (Read 10659 times)

zhousama

  • Guest
Hello World Fail
« on: February 21, 2014, 09:26:00 pm »
Hello,

I'm just starting to learn C++ and installed Codeblocks. I copied the HelloWorld program but immediately get an error:
C:\Users\...\New folder\Untitled5.c|2|fatal error: iostream: No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

This is the program:
// my first program in C++
#include <iostream>

int main()
{
  std::cout << "Hello World!";
}

I'm think the error lies in the standard libraries not being included in the build path, but I'm not sure which directories to include. Any ideas?

Thanks in advance!

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Hello World Fail
« Reply #1 on: February 21, 2014, 09:48:42 pm »
you are trying to compile a c++ program with a c compiler. C::B looks at the file ending to get the right compiler. So if you want to compile a c++ program  (iostream) your file needs the cpp or cxx ending and not c.

greetings

PS. please use code tags for log and code in this forum

Offline quneur

  • Single posting newcomer
  • *
  • Posts: 3
Re: Hello World Fail
« Reply #2 on: May 09, 2014, 04:53:24 pm »
int main requires a return type.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Hello World Fail
« Reply #3 on: May 09, 2014, 05:27:58 pm »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org