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

  • SEARCH
  • Home
  • 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 116445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:10:45+00:00 2026-05-11T03:10:45+00:00

I’ve singled out a runtime error on this line of my code: for (synsAuxCopyIndex=1;

  • 0

I’ve singled out a runtime error on this line of my code:

for (synsAuxCopyIndex=1; synsAuxCopyIndex<synsAux.size(); synsAuxCopyIndex++) 

Which is runnhing inside the pushSynonyms(string synline, vector<WordInfo> &wordInfoVector) function. I don’t get why is this particular line generating the error, as I don’t think I’m indexing anything out of range.

The debugger is saying:

Uncontrolled Exception 0x00411cbf in program.exe: 0xC0000005: Infracción de acceso al leer la ubicación 0x00000000. 

I guess ‘Infracción de acceso’ will translate as Unauthorized access on an English debugger.

The input file is

dictionary.txt

1 cute 2 hello 3 ugly 4 easy 5 difficult 6 tired 7 beautiful synonyms 1 7 7 1 antonyms 1 3 3 1 7 4 5 5 4 7 3 

#include <iostream> #include <fstream> #include <string> #include <sstream> #include <vector>  using namespace std;  class WordInfo{  public:                   WordInfo() {}    ~WordInfo() {}    int id() const { return myId; }    void readWords(istream &in) {     in >> myId >> word;        }    vector<int>& getSynonyms () {     return mySynonyms;   }    vector<int>& getAntonyms() {      return myAntonyms;   }    string getWord() {     return word;   }    void pushSynonyms (string synline, vector<WordInfo>& wordInfoVector) {     stringstream synstream(synline);     vector<int> synsAux;     int num;     while (synstream >> num)       synsAux.push_back(num);     int wordInfoVectorIndex;     int synsAuxCopyIndex;     for (wordInfoVectorIndex=0;          wordInfoVectorIndex < wordInfoVector.size();          wordInfoVectorIndex++) {       if (synsAux[0] == wordInfoVector[wordInfoVectorIndex].id()) {         // this is the line that's generating a Runtime Error, Why?                                                                for (synsAuxCopyIndex = 1;              synsAuxCopyIndex < synsAux.size();              synsAuxCopyIndex++) { //        wordInfoVector[wordInfoVectorIndex].mySynonyms.push_back( //            synsAux[synsAuxCopyIndex]);         }                                                                 }          }   }    void pushAntonyms (string antline, vector<WordInfo> wordInfoVector) {     stringstream antstream(antline);     vector<int> antsAux;     int num;     while (antstream >> num)       antsAux.push_back(num); //    for (int i=0; i<antsAux.size(); i++){ //      cout<<antsAux[i]<<endl;   //    }   }    //--dictionary output function   void printWords (ostream &out) {     out<<myId<< ' '<<word;        }    //--equals operator for String   bool operator == (const string &aString) const {     return word ==aString;    }    //--less than operator   bool operator < (const WordInfo &otherWordInfo) const {     return word<otherWordInfo.word;   }    //--more than operator   bool operator > (const WordInfo &otherWordInfo) const {     return word>otherWordInfo.word;   }   public:    vector<int> mySynonyms;   vector <int> myAntonyms;   private: //vector <int> mySynonyms; //vector <int> myAntonyms;   string word;   int myId; };  //--Definition of input operator for WordInfo istream & operator >> (istream &in, WordInfo &word) {   word.readWords(in);  }  //--Definition of output operator ostream & operator << (ostream &out, WordInfo &word) {   word.printWords(out);   }  int main() {   string wordFile;   cout << 'enter name of dictionary file: ';   getline (cin, wordFile);   ifstream inStream(wordFile.data());   if (!inStream.is_open()) {     cerr << 'cannot open ' << wordFile << endl;      exit(1);                         }    vector <WordInfo> wordInfoVector;    WordInfo aword;    while (inStream >> aword && (!(aword == 'synonyms')))     wordInfoVector.push_back(aword);    inStream.clear();    int i=0;             while (i < wordInfoVector.size()) {     cout << wordInfoVector[i] << endl;     i++;   }    vector <int> intVector;   string synLine;     while (getline(inStream, synLine) && (synLine != ('antonyms')))     aword.pushSynonyms(synLine, wordInfoVector);    int theIndex;   for (theIndex=0;        theIndex < wordInfoVector[0].mySynonyms.size();        theIndex++)     cout << 'the synonyms of 1 are ' <<         wordInfoVector[0].mySynonyms[theIndex] << endl;   cout << 'the size of mySynonyms of 1 is ' <<       wordInfoVector[0].mySynonyms.size() << endl;    for (theIndex=0;        theIndex < wordInfoVector[0].mySynonyms.size();        theIndex++)       cout << 'the synonyms of 7 are ' <<         wordInfoVector[6].mySynonyms[theIndex] << endl;   cout << ' the size of mySynonyms of 7 is ' <<       wordInfoVector[6].mySynonyms.size() << endl;    string antLine;   while (getline(inStream, antLine))     aword.pushAntonyms(antLine, wordInfoVector);        wordInfoVector[0].mySynonyms.push_back(1);   system('PAUSE');   return 0;           } 
  • 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. 2026-05-11T03:10:45+00:00Added an answer on May 11, 2026 at 3:10 am

    If you add some debugging output to your program, you’d notice you never enter or even reach the ‘culprit’ for-loop.

    The problem is actually the test against ‘synsAux[0]’ right above it – synxAux.size() is zero, so accessing the zeroth element is an index out-of-bounds error.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker

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.