title: Getting an error in my function that returns values in an array using pointers in C
body: <p>I am trying to learn arrays and pointers in C. I'm trying to write a program that in a function: gets 2 numbers from the user, puts them in an array, and returns them to the main function. I am getting an error and I don't understand what the problem is. Here is my code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  void get_nums(float *x)
  {
      float num1, num2;
  
      printf("enter two numbers: ");
      scanf("%f %f", &amp;num1, &amp;num2);
  
      *x[0] = num1;
      *x[1] = num2;
  
  }
  
  main(){
  
      float x[2];
      float (*p_x)[2] = &amp;x;
  
      get_nums(p_x[2]);
  
      printf("Number 1: %f\nNumber 2: %f", x[0], x[1]);
  
      return 0;
  }
  </code></pre>
  
  <p>I am getting an error on these 2 lines</p>
  
  <pre><code>    *x[0] = num1;
      *x[1] = num2;
  </code></pre>
  
  <p>The error message is</p>
  
  <blockquote>
    <p>Error: operand of '*' must be a pointer</p>
  </blockquote>
  
  <p>I don't see what it is that is wrong. Does anyone see the problem?</p>
  
  <p>EDIT: I changed the 2 lines to </p>
  
  <pre><code>    x[0] = num1;
      x[1] = num2;
  </code></pre>
  
  <p>and now I can run the program. However I get a new error after I enter the two numbers. The error message is: </p>
  
  <blockquote>
  <pre><code>  Unhandled exception at 0x40e00000 in arraysandpointers.exe: 0xC0000005: Access violation.
  </code></pre>
  </blockquote>