News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Hello World Fail

Started by zhousama, February 21, 2014, 09:26:00 PM

Previous topic - Next topic

zhousama

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!

BlueHazzard

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

quneur

int main requires a return type.

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]