Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 795665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:30:58+00:00 2026-05-14T22:30:58+00:00

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

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T22:30:59+00:00Added an answer on May 14, 2026 at 10:30 pm

    Another suggestion: declare output text as one entity, then block write. This may make your programs easier to debug, read and understand.

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

    For Your Information (FYI):

    1. stdafx.h is not a standard header
      and not required for small projects.
    2. conio.h is not a standard header
      and not required for simple console
      I/O.
    3. Prefer string for text rather than
      char *.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are trying to debug some web services code we're running in C# on
I am trying to debug code using gdb, but when I try to watch
I'm trying to debug some IE-only issues for a site I'm developing. I'm running
I'm trying to debug an MSBuild task, and I know there is some way
I am trying to use the Event Log to write some debug information and
Trying to debug some linker errors, I turned on /VERBOSE and I'm trying to
I am trying to debug some COM components and want to track down CLSID
I am trying to debug some win32API's like Createthread which returns a handle. How
I am trying to debug some errors in a live Merb app. There are
I am trying to debug some exe in windbg. Now its calling some thirdparty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.