Cannot Create a Lazy String and cannot access memory

531 Views Asked by At

After getting a segmentation fault error, the debugger gives me an error that says I cannot access memory at address 0x1. It also says cannot create a lazy string with address 0x0, and a non-zero length. Does anyone know how I can fix this?

Thanks!

#include <iostream>
#include <string>
#include "unorderedSet.h"

using namespace std;
int main()
{
  int intArr[] = {12,23,4,7,12,9,10,6,23,11};
  
  //Debugger points to here
  string strArr[] = {"banana","apple","pear","grape",
  "banana","fig","mango","orange","pear","guava"};
  
  

  unorderedSet<int> intSet(20);
  for (int i = 0; i < 10; i++)
  {
    intSet.insertEnd(intArr[i]);
  }  
  
  unorderedSet<string> strSet(20);
  for (int i = 0; i < 10; i++)
  {
    strSet.insertEnd(strArr[i]);
  }  

  cout << "\nInteger Set: " << intSet << endl;
  cout << "String Set: " << strSet << endl;

  intSet.insertAt(5,30);

  cout << "\nInsert At non-duplicate\nInteger Set: " << intSet << endl;
  intSet.insertAt(5,11);

  cout << "Insert At duplicate\nInteger Set: " << intSet << endl;
  strSet.replaceAt(1,"pineapple");

  cout << "\nReplace At non-duplicate\nString Set: " << strSet << endl;
  strSet.replaceAt(3,"pear");

  cout << "Replace At Duplicate\nString Set: " << strSet << endl;

  int intArr1[] = {7,0,19,56,22,11,23,5};

  //Debugger points to here
  string strArr1[] = {"red","yellow","grape","banana","mango","orange","guava"};

  unorderedSet<int> intSet1(20);
  for (int i = 0; i < 8; i++)
  {
    intSet1.insertEnd(intArr1[i]);
  }  

  unorderedSet<string> strSet1(20);
  for (int i = 0; i < 7; i++)
  {
    strSet1.insertEnd(strArr1[i]);
  }
0

There are 0 best solutions below