title: C scanf int into struct
body: <p>I am trying to read some integers into a struct.  I am having the user enter two 3-dimensional vectors and returning two cross products and the dot product.</p>
  
  <p>It appears to be skipping the second value of the second vector.  Here's my code so far:</p>
  
  <pre><code>/** Write a program to calculate cross-products and dot products of 
  **  a 3-dimensional vector:
  **  
   **    1. Uses a type definition
  **    2. Accepts User input of qty(2) 3-dimensional vectors
  **    3. Calculate the cross-product of A x B and B x A                         
  **    4. Calculate the dot product A * B
  **
  ******************************************************************/
  
  
  /************* Preprocessor Functions       **********************/
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  
  /************ Structured Data Types ***************************/
  
  typedef struct vector
  {
      int x;
      int y;
      int z;
  } Vector;
  
  
  /*************   Declare User Functions  **********************/
  
  int dot_product(Vector a, Vector b);
  Vector cross_product(Vector a, Vector b);
  
  /************     Begin MAIN LOOP     *************************/
  
  int main(void)
  {
  /**      Declare variables     **/
      Vector a, b, c;
  
      printf("Enter the 3 integer components of the first vector: ");
      scanf("%d%d%d", &amp;(a.x), &amp;(a.y), &amp;(a.z));
      printf("Enter the 3 integer components of the second vector: ");
      scanf("%d%d%d", &amp;(b.x), &amp;(b.y), &amp;(b.y));
      c = cross_product(a, b);
      printf("\n\t(%d %d %d) x (%d %d %d) = (%d %d %d)",   a.x,a.y,a.z,b.x,b.y,b.z,c.x,c.y,c.z);
      c = cross_product(b, a);
      printf("\n\t(%d %d %d) x (%d %d %d) = (%d %d %d)", b.x,b.y,b.z,a.x,a.y,a.z,c.x,c.y,c.z);
      printf("\n\t(%d %d %d) * (%d %d %d) = %d\n", a.x,a.y,a.z,b.x, b.y,b.z,dot_product(a, b));
  
   /***********   AND CUT!  It's a wrap folks!  Take 5!     ***********/    
      return 0;
  }
  
  /**********    User Functions to perform the calculations    ****/
  
  int dot_product(Vector a, Vector b)
  {
      return((a.x*b.x)+(a.y*b.y)+(a.z*b.z));
  }
  
  Vector cross_product(Vector a, Vector b)
  {
  Vector c;
  c.x = (a.y*b.z)-(a.z*b.y);
  c.y = (a.z*b.x)-(a.x*b.z);
  c.z = (a.x*b.y)-(a.y*b.x);
  
  return(c);
  
  }
  </code></pre>
  
  <p>If the user enters: 3 2 1
  And then enters: 5 6 2</p>
  
  <p>The two vectors used are: [3 2 1] and [5 2 0]</p>
  
  <p>I have tried spaces around the %d in scanf, and no parentheses around &amp;a.x etc.</p>
  
  <p>Thanks for looking and any help is appreciated.  Just for full disclosure, this is for a C programming class I am attending.  </p>