error C2109: subscript requires array or pointer type

Posted by numerical25 on Stack Overflow See other posts from Stack Overflow or by numerical25
Published on 2010-05-13T20:13:19Z Indexed on 2010/05/13 20:14 UTC
Read the original article Hit count: 604

Filed under:
|
|

I am trying to debug some homework but I am having trouble with these lines of code

#include "stdafx.h"
#include<conio.h>
#include<iostream>
#include<string>
using namespace std;

int main()
{
   char word;
   cout << "Enter a word and I will tell you whether it is" << endl <<
 "in the first or last half of the alphabet." << endl << 
   "Please begin the word with a lowercase letter. --> ";
   cin >> word;
   if(word[0] >= 'm')
     cout << word << " is in the first half of the alphabet" << endl;
   else
     cout << word << " is in the last half of the alphabet" << endl;
   return 0;
}  

I get the following error and I have no clue what its sayings

error C2109: subscript requires array or pointer type

© Stack Overflow or respective owner

Related posts about c++

Related posts about c