title: Segmentation Fault in Function Call
body: <p>So I've got my program to the point where it compiles, but upon calling up the other functions the program drops with a Segmentation Fault(core dumped) error.
  Everything works until then. I'll add the entire code in case the setup is wrong (possible as I don't particularly understand pointers or passing values and such)</p>
  
  <pre><code>#include &lt;cmath&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  void discrim0(float a, float b, float c, float * root1, float * root2);
  void discrimmore(float a, float b, float c, float * root1, float * root2);
  void discrimless(float a, float b, float c, float * real, float * sqrtim);
  
  int main()
  {
  
   float discrim;
   float a;
   float b;
   float c;
   float * root1=0;
   float * root2=0;
   float * real=0;
   float * sqrtim=0;
   char cAgain;
  
   cout &lt;&lt; "Welcome to the quadratic roots calculator." &lt;&lt;endl;
  
   do
   {
    do
    {
  
     cout &lt;&lt; "Please enter the three coefficient values of the" &lt;&lt;endl;
     cout &lt;&lt; "quadratic equation. The coefficient of x^2 must not"&lt;&lt;endl;
     cout &lt;&lt; "be 0." &lt;&lt;endl;
  
     cin &gt;&gt; a &gt;&gt; b &gt;&gt; c;
  
     if(a==0)
     {
      cout &lt;&lt; "The value you entered for the coefficient of x^2"&lt;&lt;endl;
      cout &lt;&lt; "is not valid(0). Please enter a proper value."&lt;&lt;endl;
     }
    }while(a==0);
  
  
    discrim=(b*b)-4*a*c;
  
    if(discrim&lt;0)
     {
      cout &lt;&lt; "Your equation has two imaginary roots."&lt;&lt;endl;
      //error occurs here
      discrimless(a,b,c, real, sqrtim);
      cout &lt;&lt; *real &lt;&lt; " + " &lt;&lt; *sqrtim &lt;&lt; "i" &lt;&lt; endl;
      cout &lt;&lt; "and" &lt;&lt; endl;
      cout &lt;&lt; *real &lt;&lt; " - " &lt;&lt; *sqrtim &lt;&lt; "i" &lt;&lt; endl;
     }
  
     if(discrim==0)
     {
      cout &lt;&lt; "Your equation two roots of the same value."&lt;&lt;endl;
      //error occurs here
      discrim0(a,b,c, root1, root2);
      cout &lt;&lt; *root1 &lt;&lt; " and " &lt;&lt; *root2 &lt;&lt; endl;
     }
  
     if(discrim&gt;=0)
     {
      cout &lt;&lt; "Your equation has two real roots, which are: "&lt;&lt;endl;
      //error occurs here
      discrimmore(a,b,c, root1, root2);
      cout &lt;&lt; *root1 &lt;&lt; " and " &lt;&lt; *root2;
     }
  
     cout &lt;&lt; "Would you like to run another calculation? Y/y/N/n"&lt;&lt;endl;
     cin &gt;&gt; cAgain;
  
    }while(cAgain=='Y'||cAgain=='y');
  
    return 0;
   }
  
   void discrim0(float a, float b, float c, float * root1, float * root2)
   {
    *root1= ((-b + sqrt((b*b)-4*a*c))/2*a);
  
    *root2= ((-b - sqrt((b*b)-4*a*c))/2*a);
   }
  
   void discrimless(float a, float b, float c, float * real, float * sqrtim)
   {
    *real= (-b)/(2*a);
    *sqrtim= (sqrt(-(b*b-4*a*c)))/(2*a);
  
   }
  
   void discrimmore(float a, float b, float c, float *  root1, float * root2)
   {
    *root1= ((-b + sqrt((b*b)-4*a*c))/2*a);
  
    *root2=((-b - sqrt((b*b)-4*a*c))/2*a);
   }
  </code></pre>
  
  <p>I marked in the code where it happens. Essentially it will tell you the number of roots and then crash. I understand the general idea of seg fault that I am trying to access memory I don't have or something to that effect, but I don't really know why it is occurring. Also please keep in mind that I don't really understand technical speak too well. Thanks.  </p>