Problem with std and cout

Hello,I'm new in C++ so dont be harsh on me.
I started with the "Hello world!" program,and it doesnt work,it gives me these erors :

error C2871: 'std' : a namespace with this name does not exist
error C2065: 'cout' : undeclared identifier

How can I fix it ?

here's the code:

1
2
3
4
5
6
7
8
9
10
11
//My first program in C++

#include<iostream>
#include<stdafx.h>
using namespace std;

int main()
{
	cout<<"Hello world!!!";
	return 0;
}
I guess you are using Visual Studio.
Start an "Empty Project" and try again, other project templates may make your program fail
Still didnt worked.

I found this code written and I added #include "iostream" , can you tell me if theres a difference if I type #include <<iostream>> like this or "iostream" with quotes ?

1
2
3
4
5
6
7
8
9
10
#include "iostream"
#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)
{
    Console::WriteLine(L"Hello World");
    return 0;
}


This code is weird! Why (array<System::String ^> ^args)
and why Console::WriteLine(L

In the Documentation\Structure of a program , it doesnt say I have to write it like this.
Because the above is not C++ but C++/CLI ( which is a different language ) -- don't start a CLR Empty Project

#include "header" searches on the current directory and on the compiler include direcories
#include <header> searches only on compiler include direcories
Also, IIRC, the <stdafx.h> should be the first file #included.
Topic archived. No new replies allowed.