Home c++ What does error C2065: 'cout': undeclared identifier mean?

What does error C2065: ‘cout’: undeclared identifier mean?




I am writing a program and the following error crashes:

error C2065: ‘cout’: undeclared identifier;

What could be the reason?

Here’s the program:

# include & lt; iostream & gt;
using namespace std;
#include "stdafx.h"
void main ()
 int a, b;
 cout & lt; & lt; "Enter f-st n-bre";
 cin & gt; & gt; a;
 cout & lt; & lt; "second";
 cin & gt; & gt; b;
 cout & lt; & lt; "sum is" & lt; & lt; a + b & lt; & lt; '\ n';

Answer 1, authority 100%

The header used for precompiled headers in Visual Studio should always be the first line in the file it is included in. This requirement appeared because everything that comes before this inclusion is ignored.

Therefore, to solve your problem, you need to make #include "stdafx.h" the first line in the file.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions