title: how to solve the runtime error in this program
body: <p>i run this program and it gives the runtime error</p>
  
  <p>" Runtime error: exit code is -1073741819 ".</p>
  
  <p>can someone plz tell me why tis error occurs and how to rectify it?</p>
  
  <p>the program is finding the word ladder (length of the shortest chain to reach the target word) . i.e Given a dictionary, and two words ‘start’ and ‘target’ (both of same length). Find length of the smallest chain from ‘start’ to ‘target’ if it exists, such that adjacent words in the chain only differ by one character and each word in the chain is a valid word i.e., it exists in the dictionary. It may be assumed that the ‘target’ word exists in dictionary and length of all dictionary words is same.</p>
  
  <pre><code>#include&lt;bits/stdc++.h&gt;
  using namespace std;
  
  string dic[] = {"POON", "PLEE", "SAME", "POIE", "PLEA", "PLIE", "POIN"};
  
  int n = sizeof(dic)/sizeof(dic[0]);
  
  set&lt;string&gt; graph;
  
  struct word
  {
      string s;
      int d;
  };
  
  bool isAdj(string &amp;s , string &amp;t)
  {
      int count = 0;
  
      for(int i=0; i&lt;s.length() &amp;&amp; i&lt;t.length(); i++)
         if(s[i] != t[i])
            count++;
  
      return (count == 1);      
  }
  
  int shortestPath(string s , string d)
  {
      queue&lt;word&gt; que;
  
      word source = {s , 0};
  
      que.push(source);
  
      word cur;
      //string t = "PLEA";
      while(!que.empty())
      {
          cur = que.front();
          if(cur.s == d)
             break;
  
          for(string t : graph)
          {
              if(isAdj(cur.s , t))
              {
                  word temp = {t, cur.d + 1};
  
                  que.push(temp);
                  graph.erase(t);
              }
          }
  
          que.pop();
  
      }
  
      if(cur.s == d)
          return cur.d;
    return 0;
  }
  
  main()
  {
  
      for(int i=0; i&lt;n; i++)
          graph.insert(dic[i]);
  
      cout&lt;&lt;"  "&lt;&lt;shortestPath("TOON" , "PLEA")   ; 
  }
  </code></pre>
  
  <p>the question link is here
       <a href="http://www.geeksforgeeks.org/word-ladder-length-of-shortest-chain-to-reach-a-target-word/" rel="nofollow noreferrer">http://www.geeksforgeeks.org/word-ladder-length-of-shortest-chain-to-reach-a-target-word/</a></p>
  
  <p>thanks in advance. </p>