title: C++ : How to use a pointer in an if statement condition
body: <p>I am writing a program that takes in 3 user inputted values for a quadratic equation, does some calculation, and returns how many roots the quadratic has. </p>
  
  <p>When I print <code>*(point)</code>, it gives me the correct value from the function.</p>
  
  <p>However, when I use <code>*(point)</code> in the If conditions, it does not seem to work the way I want it to - I believe that <code>*(point)</code>is always some positive number, hence why it always executing that specific if condition.</p>
  
  <p>The user values: <code>a = 9</code>, <code>b = -12</code>, <code>c = 4</code> should print out <strong>This quadratic has 1 root.</strong> and the values: <code>a = 2</code>, <code>b = 16</code>, <code>c = 33</code> should print out <strong>This quadratic has 2 roots.</strong> BUT the program always prints out <strong>This quadratic has 0 roots.</strong> no matter what the values entered.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  
  using namespace std;
  
  float *quadratic(float a1[]);
  
  int main()
  {
  
      float a1[3] = {};
      float *point;
  
      cout &lt;&lt; "Enter a: ";
      cin &gt;&gt; a1[0];
      cout &lt;&lt; "\nEnter b: ";
      cin &gt;&gt; a1[1];
      cout &lt;&lt; "\nEnter c: ";
      cin &gt;&gt; a1[2];
  
      point = quadratic(a1);
  
      cout &lt;&lt; endl &lt;&lt; "d = " &lt;&lt; *(point) &lt;&lt; endl; 
  
      if (*(point) &lt; 0) {
          cout &lt;&lt; "\nThis quadratic has 2 roots.\n";
      }
      else if (*(point) &gt; 0) {
          cout &lt;&lt; "\nThis quadratic has 0 roots.\n";
      }
      else { //else if *(point) is equal to 0
          cout &lt;&lt; "\nThis quadratic has 1 root.\n";
      }
  
      return 0;
  }
  
  float *quadratic(float a1[]) {
  
      float d;
      d = (a1[1] * a1[1]) - (4 * a1[0] * a1[2]);
  
      float xyz[1] = { d };
      return xyz;
  
  }
  </code></pre>