Cin.getline() help

I want to check if the first char is a 'n'. Not sure why i get an error at the if(x=='n') part.

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
 #include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
using namespace std;

int main() {

	char x [25];

	cin.getline(x, 2);

	

	if (x == 'n') {

		cout << " Hello" << endl;
	}
	else {

		cout << " goodbye" << endl;
	}

	system("pause");
	return 0;
}
closed account (iw7Gy60M)
if (x == 'n')

x is an array. To access the first element of an array, you must use x[0].

Thank you
Topic archived. No new replies allowed.