title: scanf in C- Spaces cause deletion
body: <p>I wrote this code to find the roots of a quadratic equation.It seems to work unless I put a space before the scanning part. (for example in the input I write: <code>a=1,b=2, c=1</code>). In that case it just deletes the variable. (In the example I gave <code>c</code> would be deleted from the input and as such the answers I receive are 0,-2 instead of -1.).  The code works if I put the space somewhere else (<code>a  =1,b= 2,c=1</code>). </p>
  
  <p>How can I fix this problem?</p>
  
  <pre><code>int main()
  {
      double root1 = 0, root2 = 0;
      double a = 0., b = 0., c = 0.;
      printf("Enter a polynomial:\n");
      scanf("a=%lf,b=%lf,c=%lf", &amp;a, &amp;b, &amp;c);
  
      {
          if (a == 0)
          {
              return 0;
          }
          if ((b * b - 4 * a * c) == 0)
          {
              root1 = -b / 2 * a;
              printf("root is %f", root1);
          }
          else if ((b * b - 4 * a * c) &lt; 0)
          {
              printf("There are no roots");
          }
          else {
              root1 = (-b + sqrt(b * b - 4 * a * c)) / 2* a;
              root2 = (-b - sqrt(b * b - 4 * a * c)) / 2* a;
              printf("Roots are %f,%f", root1, root2);
          }
      }
      return 0;
  }
  </code></pre>