title: works in debugger mode. Crashes in executable mode
body: <p>The code was written in VS community 2013. The program worked fine in debugger mode. But crashed while execution. Please let me know what could be the problem.
  sample test case:
  10
  aaa
  bbb
  ccc
  aaa </p>
  
  <p>The program crashed at 3rd input line, sometimes at 4th input line.</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string.h&gt;
  #include&lt;string&gt;
  using namespace std;
  class registeration
  {
  public:
      char* name;
      int count;
      registeration *next;
  
      registeration()
      {
          name = new char(20);
          count = 0;
          next = NULL;
      }
  };
  int main()
  {
      int n;
      cin &gt;&gt; n;
      char* str = new char(n);
      registeration *regStart = new registeration();
  
      while (n--)
      {
          cin &gt;&gt; str;
          if (regStart-&gt;next == NULL)
          {
              registeration *reg = new registeration();
              regStart-&gt;next = reg;
              reg-&gt;count++;
              //strcpy(reg-&gt;name, str);
              strcpy_s(reg-&gt;name, 20, str);
          }
          else
          {
              registeration *reg = new registeration();
              reg = regStart-&gt;next;
              while (reg-&gt;next != NULL &amp;&amp; strcmp(str, reg-&gt;name))
              {
                  //registeration *reg1 = new registeration();
                  reg = reg-&gt;next;
              }
              if (!strcmp(str, reg-&gt;name))
                  reg-&gt;count++;
              else
              {
                  registeration *reg1 = new registeration();
                  strcpy_s(reg1-&gt;name, 20, str);
                  reg1-&gt;count++;
                  reg-&gt;next = reg1;
  
              }
          }
      }
      registeration *reg = new registeration();
      reg = regStart-&gt;next;
      while (reg != NULL)
      {
          if (reg-&gt;count &gt; 1)
              cout &lt;&lt; reg-&gt;name &lt;&lt; endl;
          reg = reg-&gt;next;
      }
      return 0;
  }
  </code></pre>