title: strcpy_s unhandled exception?
body: <p>I'm trying to use <code>strcpy_s</code>, but I'm having this error:</p>
  
  <blockquote>
    <p>Unhandled Exception...</p>
  </blockquote>
  
  <pre><code>struct Item { 
      //Item's 
      int code; // Code 
      char* name[20];  
  
      int amount; //Amount in stock 
      int minAmount; //Minimum amount
  
      float price; //Price
  }; 
  </code></pre>
  
  <p>The important lines are the beginning and the line with the <code>"@@@@@@@@@"</code> beside it. (<code>spot = 0</code>, <code>name</code> string was received, <code>store</code> was initialized in <code>main()</code>).</p>
  
  <pre><code>    //add an item to store
  void addItem(Item* store, int maxItems, int &amp;numItems)
  {
      if (maxItems == numItems)
      {
          cout &lt;&lt; "ERROR \n";
          return;
      }
  
      int spot = numItems; // our item's spot in store[]
      int code; // inputted code
  
      //Item's attributes' input
  
      cout &lt;&lt; "enter code : \n"; //code
      cin &gt;&gt; code;
      store[spot].code = code; //Code
  
      cout &lt;&lt; "enter name : \n"; //Name
  
      _flushall();
      char* name = new char[20];
      gets_s(name, 20);
  
      numItems++; //forward the number of items
  
      strcpy_s(*store[spot].name, 20, name); //Name UNHANDLED EXCEPTION @@@@@@@@@@@@@@@@@@@@@@@@@@@@
  
      cout &lt;&lt; "enter amount : \n"; //Amount in stock
  
      do
      {
          cin &gt;&gt; store[spot].amount;
  
          if (store[spot].amount &lt; 0) //not negative
              cout &lt;&lt; "ERROR \n";
  
      } while (store[spot].amount &lt; 0);
  
      cout &lt;&lt; "enter minimum amount : \n"; //Minimum amount for orders
  
      do
      {
          cin &gt;&gt; store[spot].minAmount;
  
          if (store[spot].minAmount &lt; 0) //not negative
              cout &lt;&lt; "ERROR \n";
  
      } while (store[spot].minAmount &lt; 0);
  
      cout &lt;&lt; "enter price : \n"; //Price
  
      do
      {
          cin &gt;&gt; store[spot].price;
  
          if (store[spot].price &lt; 0) //not negative
              cout &lt;&lt; "ERROR \n";
  
      } while (store[spot].price &lt; 0);
  }
  </code></pre>