Cant find iostream

Hey cplusplus

I am 100% new to programming, only been doing it for a few weeks just for fun.
I am currently trying to follow this tutorial: http://cplusplus.com/doc/tutorial/program_structure/ and it doesnt work for me.

Ive followed it before and made a successfull program, but now when i do it it doesnt work.

Im using Code Blocks to compile with.

This is copy pasted from the tutorial but still doesnt work for me:


#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World!";
return 0;
}


C:\Users\Nicholas\Desktop\c++ Projekt\First c++ project.c|3|error: iostream: No such file or directory|
C:\Users\Nicholas\Desktop\c++ Projekt\First c++ project.c|4|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'namespace'|
C:\Users\Nicholas\Desktop\c++ Projekt\First c++ project.c||In function 'main':|
C:\Users\Nicholas\Desktop\c++ Projekt\First c++ project.c|8|error: 'cout' undeclared (first use in this function)|
C:\Users\Nicholas\Desktop\c++ Projekt\First c++ project.c|8|error: (Each undeclared identifier is reported only once|
C:\Users\Nicholas\Desktop\c++ Projekt\First c++ project.c|8|error: for each function it appears in.)|
||=== Build finished: 5 errors, 0 warnings ===|




---------

Anyone got any idea whats going wrong? Since ive done it before but im on another computer and wanna try to keep going.

Help is appreciated

//Nic
I had that problem a lot when I was trying to compile with Code::Blocks. I can't remember exactly how it was I resolved that problem for the time being but I now use NetBeans instead. Try making sure that you have opened up a C++ source file in your project and not a C, assuming that Code::Blocks can also compile C I can't remember.
Try running a search on your computer for "iostream".

If the file doesn't exist... then it looks like the runtime library didn't get installed properly/at all. I would try reinstalling. Make sure you get a "full" installation package and not just some weird "compiler and IDE only" package.

If the file does exist you'd have to adjust your compiler settings so it looks in whatever directory for the file. I forget how to do this in C::B, but there should be some info in the C::B getting started / setup tutorials.
When you create a new file (when creating a new empty project) within Code::Block save it as ".cpp" instead of ".c" ("file_name.cpp"). Otherwise it won't find iostream.
Topic archived. No new replies allowed.