title: How do I pass a pointer to a local variable?
body: <p>I am having some trouble passing pointers to local variables. When I try printing the <code>printf</code> statement in <code>main()</code>, I get random numbers each time. But when I print it from the parse function, it works fine. I have tried playing around with the pointers and cannot figure it out.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  
  void parse(char record[], int *acct, float *amnt){
              char word1[10], word2[10];
              sscanf(record, "%s %s", word1, word2);
  
              acct = (int*) malloc(10);
              amnt = (float*) malloc(10);
  
              *acct = atoi(word1);
              *amnt = atof(word2);
  
              printf("%d, %.1f\n", *acct, *amnt);
  }
  
  int main(){
              FILE *p = fopen("accounts.ssv", "rt");
              char record[20];
              int acct;
              float amnt;
  
              while (fgets(record, 20, p)){
                      parse(record, &amp;acct, &amp;amnt);
                      printf("%d, %.1f\n", acct, amnt);
              }
  
              fclose(p);
              return 0;
  }
  </code></pre>
  
  <p>accounts.ssv</p>
  
  <pre><code>20 -50.5
  10 60.5
  20 30.0
  </code></pre>