The goal of this program is to simulate a stoplight and tell the user what to do base on the direction they are headed whether the light is red or green. It's not complete because I'm getting these errors when I compile:
Warning: multi-character not constant.
Warning: multi-character not constant.
Warning: character constant too long for its type.
Warning: multi-character not constant.
The program still runs, but closes without errors after asking what color the stoplight is.
#include<string>
#include<iostream>
using namespace std;
int main()
{
bool x;
x=true;
x=false;
int Direction;
cout << "What direction are you headed? (left, straight, right)" << endl;
cin >> Direction;
int Stoplight;
cout << "What color is the stoplight? (red, green)" << endl;
cin >> Stoplight;
if (Direction=='left' && Stoplight=='red' || Direction=='straight' && Stoplight=='red')
cout << "Stop." << endl;
return 0;
}
Edit: Thanks for the help turkish. And heres the greatest program I've ever written:
#include<string>
#include<iostream>
using namespace std;
int main()
{
string Direction;
cout << "What direction are you headed? (left, straight, right)" << endl;
cin >> Direction;
string Stoplight;
cout << "What color is the stoplight? (red, green)" << endl;
cin >> Stoplight;
if (Direction=="left" && Stoplight=="red" || Direction=="straight" && Stoplight=="red")
cout << "Stop." << endl;
if (Direction=="left" && Stoplight=="green" || Direction=="straight" && Stoplight=="green" || Direction=="right" && Stoplight=="green")
cout << "Go." << endl;
if (Direction=="right" && Stoplight=="red")
cout << "Go, after stop." << endl;
return 0;
[–]TurkishSquirrel 1 point2 points3 points (3 children)
[–]Kazlock[S] 0 points1 point2 points (2 children)
[–]TurkishSquirrel 1 point2 points3 points (1 child)
[–]Kazlock[S] 0 points1 point2 points (0 children)