Cant get this to work

Im trying to compare two character-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <string.h>
#include <string>
#include <sstream>
#include <fstream>
using namespace std;

int main()
{
	char h[5];
	char l[5]="Open";
	cout<<"*****Menu*****\n"<<"Open\n"<<"New\n";
	cin>>h;
	if (h==l)
	{
		int i;
		cout<<"works";
		cin>>i;
    }
	else
	{
		cout<<"Hey";
	}
}


But instead it always returns the else statement.
Any Help?
Use strcmp( char, char ) when comparing characters.
http://www.cplusplus.com/reference/clibrary/cstring/strcmp/

To use h == l use strings.
1
2
3
4
5
string h;
string l;

if( h == l )
    //true if they are the same 
Last edited on
Ok thanks
Topic archived. No new replies allowed.