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 7065311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:56:27+00:00 2026-05-28T04:56:27+00:00

I have been debugging this program to find the error but couldn’t succeed in

  • 0

I have been debugging this program to find the error but couldn’t succeed in that. For some reason, it is displaying an error – array index out of bounds in this line
moves[nCount].sDirection = sStep[0]; I know, this forum is not meant for debugging, im sorry for that.

      class Program
{
     struct move
    {
       public char sDirection;
       public int steps;
    }
    static void Main(string[] args)
    {
        int nNumOfInstructions = 0;
        int nStartX = 0, nStartY = 0;
        move[] moves = new move[nNumOfInstructions];


        nNumOfInstructions=Convert.ToInt32(Console.ReadLine());


        string sPosCoOrd = Console.ReadLine();
        nStartX = Convert.ToInt32(sPosCoOrd[0]);

        nStartY = Convert.ToInt32(sPosCoOrd[2]);

        string sStep = "";

        for (int nCount = 0; nCount < nNumOfInstructions; nCount++)
        {
            sStep = Console.ReadLine();
            int length = sStep.Length;
            moves[nCount].sDirection = sStep[0];
            moves[nCount].steps = Convert.ToInt32(sStep[1]);


        }


        Console.ReadLine();
    }
}
  • 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-28T04:56:28+00:00Added an answer on May 28, 2026 at 4:56 am

    In your code, the moves array is created as an array of zero length. For any index, accessing this array will inevitably throw an Array index out of bounds

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been debugging a program for some time. The code below is part
I have been playing around with some debugging and wrote some C code that
I have been trying to get this program to work but so far having
I see some related questions have been asked, but they're either too advanced for
I have been debugging this the entire day. I have two models in my
I have been debugging the infamous EXC_BAD_ACCESS error for a few days now. NSZombieEnabled
I have a rather large program that have some odd behaviour once in a
I have been debugging a Python program which segfaults after receiving a KeyboardInterrupt exception.
I have a program that I run and in the middle I get this
Is OutputDebugString(PAnsiChar('')); thread safe? I/we have been using it in threads for debugging, and

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.