compare to a word

i need to compare a char or a string to a word but i get a compiler error. what am i doing wrong?

1
2
3
4
5
6
7
8
9
10
11
char move[5];
cin >> move;
				
if (move = "up"){
	cout << "you moved up";}
if (move = "down"){
	cout << "you moved down";}
if (move = "right"){
	cout << "you moved right";}
if (move = "left"){
	cout << "you moved left";}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <string>
#include <fstream>
using namespace std;


int main(int argc, const char * argv[])
{
cout << "Input Move: ";
char move[5];
cin >> move;
				
if (move == "up")
{
	cout << "you moved up";}
else
if (move == "down"){
	cout << "you moved down";}
else
if (move == "right"){
	cout << "you moved right";}
else
if (move == "left"){
	cout << "you moved left";}

    return 0;
}
Last edited on
Topic archived. No new replies allowed.