Error with #include <iostream>

I'm having problems with this code -

1
2
3
4
5
6
7
8
// my first program in C++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}


I keep getting this error -

1
2
3
4
5
6
7
mingw32-gcc.exe    -c C:\Users\DuckkTV\Desktop\HelloWorld\HelloWorld.c -o C:\Users\DuckkTV\Desktop\HelloWorld\HelloWorld.o
C:\Users\DuckkTV\Desktop\HelloWorld\HelloWorld.c:2:20: iostream: No such file or directory
C:\Users\DuckkTV\Desktop\HelloWorld\HelloWorld.c: In function `main':
C:\Users\DuckkTV\Desktop\HelloWorld\HelloWorld.c:4: error: syntax error before ':' token
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 0 warnings (0 minutes, 0 seconds)
  


Please help!
Last edited on
1 Error is you just have "return" on line 7. That needs to be "return 0;"
That was a copy and paste error :) fixed the "return 0;" on line 7
Still having problems with the #include <iostream>
1
2
3
4
5
6
7
8
9
10
#include "stdafx.h"
#include <iostream>

using namespace std;

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


Give that a try. I was having the same error and this fixed it.
if you want to show hello world, you need to use only one 'cout'.
#include<iostream.h>
int main()
{
cout<<"Hello world"<<endl;
return 0;
}
If #include <iostream.h> works you should think about updating your compiler.
@powerbg We weren't talking about he cannot see the results. He cannot compile it. Also use Code tags.

The stdafx thingy shouldn't be your case, as your project is on your desktop, and stdafx is a VS's thing who by default puts your projects in the Documents folder.

Also try renaming your files from .c to .cpp
Last edited on
Still no luck :( What do you use to code/ writing program? I am currently using codeblocks. But I don"t know all my ways around it. Right now what i do is
 
File< New< Empty File

Could that the the problem ?
@EssGeEich
How do i rename it to CPP in CodeBlocks ?
Last edited on
You should remove the file from the project, rename it manually, and re-add the file to the project.
try right clicking on the file and selecting "rename" from the context menu.
IT WORKED !!!!!!
Thanks man!
@Disch There is no Rename in C::B
@DuckkTV You're Welcome

EDIT: I must be blind, I just noticed there is a Rename File.
Last edited on
oh lol
were is the renmame button ?
Okay thanks!
Topic archived. No new replies allowed.