EnlightEND EnlightEND - 3 years ago 207
C++ Question

error: cout was not declared and is giving me compiling problems

#include <ostream>
#include <string>

using namespace std;
int main()
{
char c = 'x';
int i1 = c;
int i2 = 'x';
char c2 = i1;
cout << c << ' << i1 << ' << c2 << '\n';
}


I keep getting error: 'cout' was not declared in this scope.
warning: character constant too long for its type (enabled by default)

Answer Source

You need

#include <iostream>

That's where std::cout is defined. (And you don't need #include <ostream>.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download