Cout, endl, and cin undeclared identifier error

I have run into this issue as well in the past, before building the solution, have you tried cleaning the solution? (in the same menu)
It fixed some code for me a few times but in some cases had to cut my loses and just make a new project and paste it into a new source file.

Also your "stdafx.h" may also need
#include<iostream>
using namespace std;