title: C pass by reference "returns" incorrect content
body: <p>I want to read some values from a file using a function and pass them to main. 
  The file has specific format: </p>
  
  <blockquote>
    <p>string double char</p>
  </blockquote>
  
  <p>For example 2 lines:    </p>
  
  <blockquote>
    <p>blahblah 0.12 G<br>
       testtesttest 0.33 E</p>
  </blockquote>
  
  <p>I have the following program. Although values are printed correctly in the function, in main only a few of them are printed. The rest are 0.00000 and no character is printed as well. What am I doing wrong? </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;string.h&gt;
  
  int read_file(const char *filename, double **prob, char **sense);
  
  int main(){
  
      double *iprob;
      char *sense;
  
      read_file("test.txt", &amp;iprob, &amp;sense);
  
      printf("Main: %lf %c\n", iprob[0], sense[0]);
  
      return 0;
  }
  
  
  int read_file(const char *filename, double **prob, char **sense){
  
      FILE *fp;
      char line[100], temp[80];
      int i = 0;
  
      fp = fopen(filename, "r");
      if (fp == NULL){
          fprintf(stderr,"File %s not found!\n", filename);
          return 0;
      }
  
      //*prob = (double *)malloc(sizeof(double) * 100);
      //*sense = (char *)malloc(sizeof(char) * 100);
  
      while( fgets(line, 100, fp) != NULL){
  
          prob[i] = (double *)malloc(sizeof(double));
          sense[i] =  (char *)malloc(sizeof(char));
  
          if ( sscanf(line, "%s %lf %c", temp, prob[i], sense[i]) &lt; 3 ){
  
              fprintf(stderr, "Parsing error detected at line %d!", i);
              fclose(fp);
              return 0;
          }
          else{
  
              printf("%lf %c\n", *prob[i], *sense[i]);
          }
          i++;
      }
      fclose(fp);
      return 1;
  }
  </code></pre>