title: How to use pointers to return multiple values from a function in C
body: <p>I am currently writing a program for a assigment which requires the use of a function to enable the user to input 3 vairables. I am having difficulty returning these variables to my main function, I have seen other similar questions previously asked and have attempted to use pointers but am unable to get it working. My attempt is below:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  //Function Header for positive values function
  double get_positive_value(double* topSpeed, double* year, double* 
  horsepower);
  
  int main(void){
  
      int reRunProgram = 0; 
  
      while (reRunProgram==0)
      {
          //variable declarations
          double tS;
          double yR;
          double hP;
          int menuOption;
          int menuOption2;
  
          //menu
          printf("1.Create Bugatti\n");
          printf("2.Display Bugatti\n");      
          printf("3.Exit\n");
  
          //user choice
          scanf("%d", &amp;menuOption);
  
          //Create car    
          if (menuOption == 1) {
  
              //run the get positive values function
              get_positive_value (&amp;tS, &amp;yR, &amp;hP);
  
              printf("top speed is %lf\n", tS);
          }
  
          //Display car (but no car created)
          else if (menuOption == 2){
              printf("error no car created\n");
          }
  
          //Exit  
          else if (menuOption ==3){
              exit(EXIT_FAILURE);
          }
  
      }   
      return 0;
  }
  
  
  double get_positive_value(double*  topSpeed, double* year, double* 
  horsepower)
  {
      do  {
          printf("Please enter the top speed of the bugatti in km/h\n");
          scanf("%lf", &amp;topSpeed);
      } while(*topSpeed&lt;=0);
  
      do{
          printf("Please enter the year of the bugatti, in four digit form (e.g. 1999)\n");
          scanf("%lf", &amp;year);
      } while(*year&lt;=0);
  
      do{
          printf("Please enter the horsepower of the bugatti\n");
          scanf("%lf", &amp;horsepower);
      } while(*horsepower&lt;=0);
  }
  </code></pre>