So, I have this question. Why does cout throws
error C2065: 'cout' : undeclared identifier
I am using Visual Studio 2012 as an IDE and I am writing a school project. I have everything done except an example file. So I am trying to write something on the screen like this:
#include "iostream"
#include "stdafx.h"
using namespace std;
int main()
{
cout<<"example";
return 0;
}
So the problem is with cout... printf works fine, but I want to use cout.
EDIT: I've changed "" to <> but it is not helping. Also I am using this code only for example... This is not the whole project.
stdafx.h
shall be the first include directive in your source file.
Switch files and convert the second include to <>
, as other suggested.
#include "stdafx.h"
#include <iostream>
See this post for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With