Error with #include <iostream>

DuckkTV (10)
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
Legomaster6060 (8)
1 Error is you just have "return" on line 7. That needs to be "return 0;"
DuckkTV (10)
That was a copy and paste error :) fixed the "return 0;" on line 7
Still having problems with the #include <iostream>
Phazon (26)
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.
powerbg (4)
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;
}
EssGeEich (1009)
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
DuckkTV (10)
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 ?
DuckkTV (10)
@EssGeEich
How do i rename it to CPP in CodeBlocks ?
Last edited on
EssGeEich (1009)
You should remove the file from the project, rename it manually, and re-add the file to the project.
Disch (8617)
try right clicking on the file and selecting "rename" from the context menu.
DuckkTV (10)
IT WORKED !!!!!!
Thanks man!
EssGeEich (1009)
@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
DuckkTV (10)
oh lol
DuckkTV (10)
were is the renmame button ?
EssGeEich (1009)
Given project name "asd" ---> http://dl.dropbox.com/u/83943521/Screens/f/cplpl/Rename.png
DuckkTV (10)
Okay thanks!
Registered users can post here. Sign in or register to post.