title: Debug Assertion Failed at deleted allocated memory
body: <p>I'm in a relatively basic programming class and I'm getting an error I've never come across before. It's this:</p>
  
  <pre><code>Debug Assertion Failed!
  
  Program:...sual Studio 2010\Projects\Comp Project\Debug\Comp Project.exe
  File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp
  Line: 52
  
  Expression:_BLOCK_TYPE_IS_VALID(pHead-&gt;nBlockUse)
  </code></pre>
  
  <p>Here's my code and the error pops up as the allocated memory is deleted it looks like</p>
  
  <pre><code>    //Shortest Path Version 1.01 IN PROGRESS
  /*
      This program reads in node and arc data and interpretes it into a list which it can then use
      to calculate the shortest time or distance, depending on user prefrence, between two chosen
      nodes and send pack the path to the user
  */
  #include &lt;conio.h&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  using namespace std;
  void main()
  {
      //opening the files where the data is contained.
      ifstream arcfile;
      ifstream nodefile;
      arcfile.open("G:\\Programming\\Descrete Structures\\arcs2011.txt");
      nodefile.open("G:\\Programming\\Descrete Structures\\nodes2011.txt");
  
      //creating a class that will store the data relevent to locating the shortest path
      class Arc
      {
      public:
          unsigned short int FROM;                                //from node
          unsigned short int TO;                                    //to node
          double DISTANCE;                                        //distance in miles
          double TIME;                                            //travel time
      };
  
      //creating a class that will store the data relavent to the node path
      class Node
      {
      public:
          unsigned long int WIEGHT;                                //either time or distance
          unsigned short int FROM;                                //alternativly "via"
          bool* shortestKnown;
  
      };
  
      string s;                                                    //placeholder for irrelavent string data
      unsigned short int StartingNode;                            //user selected starting node
      unsigned short int EndingNode;                                //user selected ending node
      unsigned short int ARCSIZE = 0;                                //number of Arcs in arc file
      unsigned short int NODESIZE = 0;                            //number of Nodes in node file
  
      //////////////////////Begin reading in of Arc data and Node data/////////////////////
  
      //count number of registered arcs
      while(getline(arcfile,s))
      {
          ARCSIZE++;
      }
      cout&lt;&lt;ARCSIZE&lt;&lt;" line size of arcfile"&lt;&lt;endl;
  
      //count number of registered nodes
      while(getline(nodefile,s))
      {
          NODESIZE++;
      }
      NODESIZE++;                                                    //final incrementation for +1 format
      cout&lt;&lt;NODESIZE&lt;&lt;" line size of nodefile"&lt;&lt;endl;
  
      Arc* Arclist;                                                //array that will store all the arcs
      Arclist = new Arc[ARCSIZE];                                    //based on the size of the file
      string* Nodelist;                                            //array that will store the node names
      Nodelist = new string[NODESIZE];                            //based on the size of the file
  
      //reset the streams
      arcfile.close();
      nodefile.close();
      arcfile.open("G:\\Programming\\Descrete Structures\\arcs2011.txt");
      nodefile.open("G:\\Programming\\Descrete Structures\\nodes2011.txt");
  
  
      //loop through and save the arc data to an array
      for(int i=1;i&lt;ARCSIZE;i++)
      {
          arcfile.ignore(1000,'\n');
          arcfile&gt;&gt;Arclist[i].FROM;
          arcfile&gt;&gt;Arclist[i].TO;
          arcfile&gt;&gt;Arclist[i].TIME;
          arcfile&gt;&gt;Arclist[i].DISTANCE;
      }
      //loop through and store node description. Node counting starts at 1 to link up easier with
      //the arcs. The NODESIZE has been increased by 1 to allow for this format.
      for(int i=1;i&lt;NODESIZE;i++)
      {
          getline(nodefile,Nodelist[i],'\t');                        //store node data
          nodefile.ignore(1000,'\n');                                //ignore coordinates
      }
  
      //////////////////////Begin user interface portion of program////////////////////////////////
  
      cout&lt;&lt;"Arcs and Nodes loaded."&lt;&lt;endl;
      cout&lt;&lt;"Please select by node number a starting node and ending node."&lt;&lt;endl;
      cout&lt;&lt;"(Press any key to display the list)"&lt;&lt;endl&lt;&lt;endl;
      getch();
  
      //print out the node list with numarical values
      for(int i=1;i&lt;NODESIZE;i++)
      {
          cout&lt;&lt;i&lt;&lt;" - "&lt;&lt;Nodelist[i]&lt;&lt;endl;
      }
      cout&lt;&lt;endl;
      cout&lt;&lt;"Please select a starting node: ";
      cin&gt;&gt;StartingNode;
      cout&lt;&lt;endl&lt;&lt;"Please select an ending node: ";
      cin&gt;&gt;EndingNode;
  
      ////////////////////////SOME KIND OF ERROR OCCURS PAST THIS POINT///////////////////////
  
      //delete allocated memory
      delete Arclist;
      delete Nodelist;
  
  
      getch();
  }
  </code></pre>