Reputation: 3
#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)
Upvotes: 0
Views: 5253
Reputation:
You have a syntax error, where:
cout << c << ' << i1 << ' << c2 << '\n';
you have those single quotes, causing you to pass the << operator twice in a row.
Also, use
#include <iostream>
Upvotes: 2
Reputation: 395
std::cout is defined in . Try changing your include from to .
Also, your ' << i1 << ' should be in double quotes if you want it to be a string.
Upvotes: 1
Reputation: 51226
You need
#include <iostream>
That's where std::cout
is defined. (And you don't need #include <ostream>
.)
Upvotes: 3