When I try to compile the program I get the error Cout is an undeclared identifier. Anyone know how I can fix this?
I tried creating a new project without the precompileed header option checked but it still isnt working.
source
// Magic Number Game.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <cstdlib>
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int magic;
int guess;
magic = rand();
cout << "Enter your guess: ";
cin >> guess;
if (guess == magic) {
cout << "** Right **\n";
cout << magic << " is the right number.\n";
}
else {
cout << "...Sorry, you're wrong.";
//use a nesed if statement
if(guess > magic)
cout <<" You're guess is too high.\n";
else
cout << " You're guess is too low.\n";
}
return 0;
}
errors
1>------ Build started: Project: magic number game 2, Configuration: Debug Win32 ------
1>Compiling...
1>stdafx.cpp
1>magic number game 2.cpp
1>(16) : error C2065: 'cout' : undeclared identifier
1>(17) : error C2065: 'cin' : undeclared identifier
1>(20) : error C2065: 'cout' : undeclared identifier
1>(21) : error C2065: 'cout' : undeclared identifier
1>(24) : error C2065: 'cout' : undeclared identifier
1>(28) : error C2065: 'cout' : undeclared identifier
1>(30) : error C2065: 'cout' : undeclared identifier
1>Generating Code...
1>magic number game 2 - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

New Topic/Question
Reply



MultiQuote






|