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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:12:06+00:00 2026-05-21T12:12:06+00:00

im gettin this really annoying error message. I know Im only new to this

  • 0

im gettin this really annoying error message. I know Im only new to this but it seems the type of thing I could figure out. Can anyone show me where im going wrong please?

The message at run time is:
Debug Assertion Failed!
Program:
….
File: c:\program files\microsoft visual studio 10.0\vc\include\vector
Line: 932
Expression: Vector subscript out of range

and the code is

#include "VectorIntStorage.h"
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

void VectorIntStorage::Read(istream& r)
{
    char c[13];
    r >> c;
    r >> NumberOfInts; //gets number of ints for vector

    //numberVector = new std::vector<int> numberVector;

    for(int i = 0; i < NumberOfInts; i++)
    {
        r >> numberVector[i];
        cout << numberVector[i] << endl;

        if(_sortRead) //true
        {
            for(int k = 0; k < i; k++)
            {
                if(numberVector[i] < numberVector[k])
                {
                    int temp = numberVector[k];
                    numberVector[k] = numberVector[i];
                    numberVector[i] = temp;
                }
            }
        }
    }
}

void VectorIntStorage::Write(ostream& w)
{
    for(int i = 0; i < NumberOfInts; i++)
    {
        w << numberVector[i] << endl;
        cout << numberVector[i] << endl;
    }
}

void VectorIntStorage::sortStd()
{
    sort(numberVector.begin(), numberVector.end());
}

void VectorIntStorage::sortOwn()
{
    quickSort(0, NumberOfInts - 1);
}

void VectorIntStorage::setReadSort(bool sort)
{
    _sortRead = sort;
}

void VectorIntStorage::quickSort(int left, int right)
{
     int i = left, j = right;
      int tmp;
      int pivot = numberVector[(left + right) / 2];

      while (i <= j)
      {
            while (numberVector[i] < pivot)
                  i++;
            while (numberVector[j] > pivot)
                  j--;
            if (i <= j) 
            {
                  tmp = numberVector[i];
                  numberVector[i] = numberVector[j];
                  numberVector[j] = tmp;
                  i++;
                  j--;
            }
      }

      if (left < j)
      {
            quickSort(left, j);
      }
      if (i < right)
      {
            quickSort(i, right);
      }
}

VectorIntStorage::VectorIntStorage(const VectorIntStorage& copying)
{
    //int *duplicate = new int[(copying.NumberOfInts)];
    //vector<int> *duplicate = new vector<int>;

    //std::copy(numberVector.begin(), numberVector.end(), duplicate);
    //numberVector = duplicate;
    //NumberOfInts = copying.NumberOfInts;
}

VectorIntStorage::VectorIntStorage(void)
{
}


VectorIntStorage::~VectorIntStorage(void)
{
}
  • 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-21T12:12:07+00:00Added an answer on May 21, 2026 at 12:12 pm

    We don’t have enough information to say for sure, but I suspect the failing line is r >> numberVector[i]. I suppose you meant to say int j; r >> j; numberVector.push_back(j);

    The problem is precisely what the error message says: your vector subscript (i) is out of range. Specifically, you never increase the size of your vector, so it is always of size 0. Thus, any use of operator[] is going to reference an out-of-range element.

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

Sidebar

Related Questions

This is getting really annoying for me. I only have this line for my
I keep getting this weird error message every time I'm testing my app on
I'm really struggling to understand why I'm getting this error. I'm getting it referring
I'm getting this error, not really sure why. Please help, this is urgent. UPDATE
This one may seem like a simple question, but it's really got me scratching
I am getting this error when running some unit tests (using the Test::Unit module
I would look this up on Google/MSDN, but I have no idea what it's
This is my sql code SELECT M.PartNo AS ModulePartNo, (SELECT SUM(Delivered - Allocated) FROM
Am in need of making the date format in the correct manner. Right now

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.