title: C - Floating Point Exception (core dumped)
body: <p>This function is supposed to, pixel by pixel, blur the image by turning the color of each pixel on the mean of the colors around it in a 2n+1 "radius".</p>
  
  <p>(The part where it skips to the next pixel is already implemented, don't worry).</p>
  
  <p>I successfully compiled this code:</p>
  
  <pre><code>void
  blur_pixels(image *img, pixel *p, size_t i, size_t j)
  {
    //i = current height of pixel, j = current width of pixel
    int side = 2*blurRate+1;
    int total = 0;
    int leftRight = i-blurRate;
    int upDown = j-blurRate;
    int tmpHr = 0, tmpHg = 0, tmpHb = 0;
  
    for(; upDown &lt; j+blurRate; upDown++) {
      if(upDown &gt;= 0 &amp;&amp; upDown &lt; img-&gt;height) {
        for(; leftRight &lt; i+blurRate; leftRight++) {
          if(leftRight &gt;= 0 &amp;&amp; leftRight &lt; img-&gt;width) {
            tmpHr += (p+leftRight)-&gt;r;
            tmpHg += (p+leftRight)-&gt;g;
            tmpHb += (p+leftRight)-&gt;b;
            total++;
          }
        }
      }
    }
    p-&gt;r=tmpHr/total;
    p-&gt;g=tmpHg/total;
    p-&gt;b=tmpHb/total;
  }
  </code></pre>
  
  <p>But when I run the code I get the following exception:</p>
  
  <pre><code>Floating point exception
  </code></pre>
  
  <p>Does anyone know why?</p>