title: Pointers as arguments to a function that calls scanf
body: <p>I am having some trouble with pointers.</p>
  
  <p>The gist of it is, I am trying to define pointers in one function and call that function in my main to use those pointers.
  The exact instructions for my assignment are as follows:</p>
  
  <blockquote>
    <p>Write two functions, one that reads three numbers from the keyboard
    and one that prints some information about these three numbers.</p>
    
    <p>Input Function</p>
    
    <p>Write a function that has three integer pointer parameters, and that
    asks the user to enter three whole numbers. The values entered at the
    keyboard should be read into the addresses stored in the pointer
    parameters.</p>
    
    <p>Note: recall that scanf requires the address of a variable and that
    pointers store addresses.</p>
    
    <p>Printing Values</p>
    
    <p>Write a second function called a2question2, with no return value and
    no parameters. The function should declare three integer variables
    and then use your input function to read values into these variables.
    The function should then print the sum, the average, the product, and
    the smallest and largest of these numbers.</p>
  </blockquote>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>int pntloc (int *x, int *y, int *z){
    int a = 0;
    int b = 0;
    int c = 0;
  
    printf("Please enter integer #1: ");
    scanf ("%d", &amp; a);
    printf ("Please enter integer #2: ");
    scanf ("%d", &amp; b);
    printf("Please enter integer #3: ");
    scanf ("%d", &amp; c);
  
    *x = &amp;a;
    *y = &amp;b;
    *z = &amp;c;
  
    return *x, *y, *z;
  }
  
  // Fourth function
  main (){
    int x, y, z;
    pntloc(x, y, z);
  
    int sum = 0;
    int average = 0;
    int product = 0;
    int smallest = 0;
    int largest = 0;
  
    printf ("%d", x);
  }
  </code></pre>
  
  <p>However, after the program asks me for the three integers, it crashes without doing anything.</p>
  
  <p>The first function works fine by its self (tested it by making it the main function without parameters and printed the pointer values) ie: </p>
  
  <pre><code>printf ("%d", *x);
  </code></pre>
  
  <p>So I guess the values are just not passing from one function to the next. I've tried various ways of writing the first and second function but nothing seems to work.</p>
  
  <p>The best I got was getting the program not to crash but the printed value was nowhere to what I inputted before.</p>
  
  <p>Any ideas how to do this?</p>