title: Error trying to compile program from instructor (symbols expected in define line)
body: <p>I was given a template from my instructor and then modified the code to frequency histogram of a given text. However i'm getting errors trying to compile the code. I believe the errors indicated by the compiler is at the beginning of the code. The errors have been taken a screenshot of and attached below. Thanks in advance</p>
  
  <p>errors:</p>
  
  <pre><code>test.c:6:25: error: expected declaration specifiers or '...' before '\x20'
   #define FIRST_PRINTABLE ' '  // Space character code 32, see Etter 2016 text, pp. 418-420
                           ^
  test.c:8:30: note: in expansion of macro 'FIRST_PRINTABLE'
   #define NUM_PRINTABLE (int) (FIRST_PRINTABLE-LAST_PRINTABLE+1)
                                ^~~~~~~~~~~~~~~
  test.c:11:38: note: in expansion of macro 'NUM_PRINTABLE'
   void init_array(int histogram[], int NUM_PRINTABLE);
                                        ^~~~~~~~~~~~~
  </code></pre>
  
  <p>code:</p>
  
  <pre><code>/*
   *  Comp120 - Lab 7:  Starter project -- Complete this code
   *  Character Frequency analysis -- read a text file and display frequency 
   *  analysis
   *     for all printable characters.
   *
   *  Author: J. Fall
   *  Date: Feb. 2017
   */
  
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt; 
  #include &lt;stdbool.h&gt;
  
  // Definition of printable character set 
  #define FIRST_PRINTABLE ' '  // Space character code 32, see Etter 2016 text, pp. 418-420
  #define LAST_PRINTABLE '~'
  #define NUM_PRINTABLE (int) (FIRST_PRINTABLE-LAST_PRINTABLE+1)
  
  // Function prototypes:
  void init_array(int histogram[], int NUM_PRINTABLE);
  int sum_array(const int histogram[], int NUM_PRINTABLE);
  bool isPrintable(char c);
  void compute_frequency(char* filename, int histogram[], int NUM_PRINTABLE);
  void write_histogram(int histogram[], int NUM_PRINTABLE);
  FILE* openFileRead(char* filename);
  
  int main( int argc, char* argv[] )
  {
     if (argc &lt; 2) {
        printf("Usage: freq inputFile \n");
        exit(-1);
     }
  
     int histogram[NUM_PRINTABLE];  // Array of counters -- one for each printible character
  
     compute_frequency(argv[1], histogram, NUM_PRINTABLE);
  
     write_histogram(histogram, NUM_PRINTABLE);
  
     printf( "Program complete. \n" );
  
     return 0                           ;
  }
  
  /*
   * Initialize the array of integers of given length to all zeros
   */
  void init_array(int histogram[], int NUM_PRINTABLE) 
  {
      int i = 0;
      for(i=0;i&lt;NUM_PRINTABLE;i++){
          histogram[i]=0;
      }  // TODO: write function to assign 0 too every array element.
  }
  
  /*
   * Return the sum of all items in the given array
   */
  int sum_array(const int array[], int NUM_PRINTABLE)
  {
     int i = 0;
     int sum = 0;
     for(i=0;i&lt;NUM_PRINTABLE;i++){
         sum = sum + histogram[i];
     }
     return sum; // TODO: write function to add up every element in the given array.
  }
  
  /*
   * Return true iff the character is PRINTABLE
   */
  bool isPrintable(char c)
  {
     if (c &gt;= FIRST_PRINTABLE &amp;&amp; &lt;= LAST_PRINTABLE){
         return true;
     }
     else
         return false;  // TODO:  write function to return true iff c is a printable character
  }
  
  /*
   * Compute the frequency histogram for all PRINTABLE characters in the given file
   */
  void compute_frequency(char* filename, int histogram[], int NUM_PRINTABLE)
  {
     FILE* inputFile = openFileRead(filename);
  
     init_array(histogram, NUM_PRINTABLE);
  
     char c = getc(inputFile);  // priming read -- read first character from file
     while (c != EOF) {
        if(isPrintable(c)){
        int bin = c - FIRST_PRINTABLE;// TODO: write algorithm to count the number of times character c occurs.
        histogram[bin]++;
        }
        // HINT: since array indexes start at zero, map the ASCII code for each
        //       printable charcter onto an index by subtracting FIRST_PRINTABLE
  
  
  
        // After processing previous character, read next character from file to re-prime the loop
        c = getc(inputFile);   
     }
  }
  
  /*
   * Write the frequency histogram out to the given file
   */
  void write_histogram(int histogram[], int NUM_PRINTABLE)
  {
     FILE* outputFile = stdout;  // Simplifictaion:  output is written to the console instead of to an output file.
  
     int total_count = sum_array(histogram, NUM_PRINTABLE);
     fprintf(outputFile, "Frequency Analysis Results.  Input contained %d printable characters. \n", total_count);
     fprintf(outputFile, "Char | Frequency \n");
     fprintf(outputFile, "____ | _________ \n");
     int i;
     for (i=0; i&lt;NUM_PRINTABLE; i++) {
        char ch = (char) (i + FIRST_PRINTABLE);
        double freq;
        if (histogram[i] &gt; 0) {
           double freq = histogram[i]/(double)total_count * 100;
           fprintf(outputFile, "%3c  | %9.3f%% \n", ch, freq);
        }
        else
           fprintf(outputFile, "%3c  | %9d%% \n", ch, 0);
     }
  }
  
  /*
   * Attempt to open the file for read access.
   * Peforms error check and exits if file is not accessible
   */
  FILE* openFileRead(char* filename)
  {
     FILE* inFile = fopen(filename, "r" );
     if( inFile == NULL) {
        printf( "Error opening input file %s, program terminating!\n", filename);
        exit(-1);
     }
     return inFile;
  
  }
  </code></pre>