title: Converting grayscale to ascii and writing it to a .txt file
body: <p>This is my code. the lenaArray.h is a file with the grayscale. The problem I am having is that it does not write to the file and I do not get any errors.</p>
  
  <pre><code>include stdio.h
  
  include stdlib.h
  
  include stdint.h
  
  include "lenaArray.h" 
  
  
  // Average grayscale big
  
  int avgGrayScale(int *lena){
  
     int sum = 0;
  
     for (int x = 0; x &lt; 512; x++){
  
    for (int y = 0; y&lt; 512 ; y++){
  
       sum += lena[y * 512 + x]; 
  
    }
  
  
  
  }
  
     return sum / (512 * 512);
  
  }
  
  // Average grayscale small
  
  int avgGrayScaleSmall(int *lena){
  
     int sum = 0;
  
     for (int x = 100; x &lt; 400; x++){
  
        for (int y = 100; y&lt; 400 ; y++){
  
           sum += lena[y * 400 + x]; 
  
        }
  
     }
  
     return sum / (300 * 300);
  
  }
  
  // Ascii character
  
  char characterGrayScale(int grayScale) {
  
      if (grayScale &lt; 25) return '@';
      if (grayScale &lt; 50) return '%';
      if (grayScale &lt; 75) return '#';
      if (grayScale &lt; 100) return '*';
      if (grayScale &lt; 125) return '+';
      if (grayScale &lt; 150) return '=';
      if (grayScale &lt; 175) return '-';
      if (grayScale &lt; 200) return ':';
      if (grayScale &lt; 225) return '.';
      return ' ';
  }
  
  
  int main (void) {
  
  // print average grayscale big picture
  
  int averageBigLena = avgGrayScale(&amp;lena);
  
    printf("Average grayscale big image: %d\n", averageBigLena);
  
  // print average grayscale small picture
  
  int averageSmallLena = avgGrayScaleSmall(&amp;lena);
  
    printf("Average grayscale small image: %d\n", averageSmallLena);
  
    // Print lena in ascii to a file
  
      FILE *lenaAsciiBig;
  
      lenaAsciiBig = fopen("lena_ascii_big.txt", "w");
  
      for (int x = 0; x &lt; 512; x++) {
  
          for (int y = 0; y &lt; 512; y++) {
  
              char c = characterGrayScale(lena[y * 512 + x]);
  
              fwrite(&amp;c, 1, 1, lenaAsciiBig);
  
          }
  
          char c = '\n';
  
          fwrite(&amp;c, 1, 1, lenaAsciiBig);
  
      }
  
      fclose(lenaAsciiBig);
  
      return 0;
  }
  </code></pre>