title: Why does not read in a Struct with a pointer?
body: <p>I've got this code, and for some reason the cin.get does not assign a value to the p.name[i]. I don't know why, but getline does not work aswell. I've tried to just cin.get(temp,30), to read a temp, but this dont work in the for cycle.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  typedef struct echip
  {
      char name[30];
      double price;
  };
  
  void read(echip* p, int n)
  {
  
      for (int i = 0; i &lt; n; i++)
      {
          cout &lt;&lt; "Name: ";
  
          cin.get((p + i)-&gt;name, 30);
          cin.ignore();
  
          cout &lt;&lt; (p + i)-&gt;name;
  
          cout &lt;&lt; "Price: "; cin &gt;&gt; (p+i)-&gt;price;
          cout &lt;&lt; (p+i)-&gt;price;
      }
  }
  
  int main()
  {
      echip* k;
      int n;
  
      cout &lt;&lt; "Number: "; cin &gt;&gt; n;
      k = new echip[n];
  
      read(k, n);
  
      delete[] k;
      return 0;
  }
  </code></pre>