title: Why does my program crash from an access violation after accepting user input?
body: <p>i get this strange error while ruining my program with Visual C++ 2008 Express Edition:</p>
  
  <pre><code>'Ex2.exe': Loaded 'D:\studyMA\c++\visual studio\Ex2\Ex2\Debug\Ex2.exe', Symbols loaded.
  'Ex2.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
  'Ex2.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
  'Ex2.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcp90d.dll'
  'Ex2.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcr90d.dll'
  First-chance exception at 0x1049615e in Ex2.exe: 0xC0000005: 
      Access violation reading location 0x333ee91c.
  Unhandled exception at 0x1049615e in Ex2.exe: 0xC0000005: 
      Access violation reading location 0x333ee91c.
  The program '[948] Ex2.exe: Native' has exited with code 0 (0x0).
  </code></pre>
  
  <p>class <code>product</code> looks like this: </p>
  
  <pre><code> using namespace std; 
  
   class product
   { 
   public: 
       string Product_code;
       string Product_Name;
       string Product_Category;
       string Product_Vendor;
       string Product_Discription;
       string Product_Group;
  
      void input();
      void clear_product_cell();
   };
  </code></pre>
  
  <p>I have one more class (contained in bomba.h) which contains:</p>
  
  <pre><code>     product ProductList[100];
  </code></pre>
  
  <p>I've written code in bomba.cpp, asking the user for input:</p>
  
  <pre><code> char ch;
   cout &lt;&lt; "Please Select your option: ";
   cin &gt;&gt; ch;
  
   switch(ch)
     {
       case '1'://Add a product
       {
          ProductList[0].input();
               :
               :
          :
  </code></pre>
  
  <p>product.cpp looks like this: </p>
  
  <pre><code> product::input()
  
       do{
          cout &lt;&lt; "Please enter product code: ";
          getline(cin,Product_code);
          if (Product_code.empty())
              cout &lt;&lt; "You Must Enter A Code!!!";
      } while(Product_code.empty());
      cout &lt;&lt; endl;
  </code></pre>
  
  <p>In the console, I get:</p>
  
  <blockquote>
    <p>Please Select your option: 1
    Please enter product code: </p>
  </blockquote>
  
  <p>...and when I type a number and after the number I type the CR key the program crashes and I get the errors I quoted above.</p>