title: C++ taking an array of Fahrenheit temperatures, converting them to Celsius, then adding the Celsius temperatures to a new array
body: <p>Hi so this is my first time on Stackoverflow so I apologize in advance if I'm not to clear with what I'm asking. I have an assignment for class to take an array of temperatures in Fahrenheit, convert them to Celsius, and then place those converted numbers into another array of the same size. My issue seems to be with memory locations and getting the actual value from the Fahrenheit array and performing the arithmetic to convert that value. I've searched for a while to try and find more information on this because it seems pretty basic but for some reason cannot find any help, thus my reasoning for joining Stackoverflow. Any help or suggestions (including those telling me to just blow my brains out) or links to tutorials would be greatly appreciated. </p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  void toCelsius(double fahrenheitTemps[],double *celsiusTemps,int n){
  
      for (int i = 0; i &lt; n; i++) {
          *(celsiusTemps + i) = (((*(fahrenheitTemps + i)) - 32)*(5 / 9));
          cout &lt;&lt; ((*(fahrenheitTemps + i) - 32)*(1.8)) &lt;&lt; endl;
  
      }
  
  }
  void PrintResults(double tF[], double tC[], int n) {
  
      cout &lt;&lt; "Fahrenheit Temps: ";
      for (int i = 0; i &lt; n; i++) {
          cout &lt;&lt; tF[i] &lt;&lt; " ";
      }
      cout &lt;&lt; endl;
  
      cout &lt;&lt; "Celsius Temps:    ";
      for (int i = 0; i &lt; n; i++) {
          cout &lt;&lt; tF[i] &lt;&lt; " ";   //This was my main issue and mistake (it should be tC) view update to see corrected code
      }
      cout &lt;&lt; endl;
  }
  
  int main(){
      double tempF[] = { 33.5,67.5,67.5,88.0,46.0,94.5,77.5,83.0,95.0,80.5 }, tempC[10];
      double * ptrTempF, * ptrTempC;
      *ptrTempF = &amp;tempF;
      ptrTempC = tempC;
  
      for (int i = 0; i &lt; 10; i++) {
          *(tempC + i) = (*(tempF + i) - 32)*(5 / 9);
          cout &lt;&lt; tempC &lt;&lt; " " &lt;&lt; tempC[i] &lt;&lt; endl;
      }
  
      toCelsius(tempF, tempC, 10);
      PrintResults(tempF, tempC, 10);
  }
  </code></pre>
  
  <p>Update: I'm just a complete moron everything you guys suggested genuinely fixed some of the bug problems I was having. However the reason the array <code>tempC</code> looked like it wasn't changing in the output was because I put in the function <code>printResults</code> <code>cout &lt;&lt; tF[i] &lt;&lt; " ";</code> where <code>cout &lt;&lt; tC[i] &lt;&lt; " ";</code> should have been. My output looked made it look like nothing was working since when it was. </p>
  
  <p>This is the working form of the code just in case anyone googles this and wants to see the working code:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  void toCelsius(double fahrenheitTemps[],double * &amp;celsiusTemps,int n){ //I think &amp; made a difference
  
      for (int i = 0; i &lt; n; i++) {
          celsiusTemps[i] = ((fahrenheitTemps[i] - 32.0)*(5.0 / 9.0));
      }
  
  }
  
  void PrintResults(double tF[], double tC[], int n) {
  
      cout &lt;&lt; "Fahrenheit Temps: ";
      for (int i = 0; i &lt; n; i++) {
          cout &lt;&lt; tF[i] &lt;&lt; " ";
      }
      cout &lt;&lt; endl;
  
      cout &lt;&lt; "Celsius Temps:    ";
      for (int i = 0; i &lt; n; i++) {
          cout &lt;&lt; tC[i] &lt;&lt; " ";
      }
      cout &lt;&lt; endl;
  }
  
  int main(){
      double tempF[] = { 33.5,67.5,67.5,88.0,46.0,94.5,77.5,83.0,95.0,80.5 }, tempC[10];
      double * ptrTempC;
      ptrTempC = tempC;
  
      toCelsius(tempF, ptrTempC, 10);
      PrintResults(tempF, tempC, 10);
  }
  </code></pre>