title: C extract words from a txt file except spaces and punctuations
body: <p>I'm trying to extract the words from a .txt file which contains the following sentence</p>
  
  <blockquote>
    <p>Quando avevo cinqve anni, mia made mi perpeteva sempre che la felicita e la chiave della vita. Quando andai a squola mi domandrono come vuolessi essere da grande. Io scrissi: selice. Mi dissero che non avevo capito il corpito, e io dissi loro che non avevano capito la wita.</p>
  </blockquote>
  
  <p>The problem is that in the array that I use to store the words, it stores also empty words <code>' '</code> which come always after one of the following <code>','</code> <code>'.'</code> <code>':'</code></p>
  
  <p>I know that things like "empty words" or "empty chars" don't make sense but please try the code with the text that I've passed and you'll understand.</p>
  
  <p>Meanwhile I'm trying to understand the use of <code>sscanf</code> with this modifier <code>sscanf(buffer, "%[^.,:]");</code> that should allow me to store strings ignoring the <code>.</code> and <code>,</code> and <code>:</code> characters however I don't know what should <code>i</code> write in <code>%[^]</code> to ignore the empty character <code>' '</code> which always gets saved.</p>
  
  <p>The code is the following</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  static void load_array(const char* file_name){
    char buffer[2048];
    char a[100][100];
    int buf_size = 2048;
    FILE *fp;
    int j = 0, c = 0;
  
    printf("\nLoading data from file...\n");
  
    fp = fopen(file_name,"r"); 
  
    if(fp == NULL){
      fprintf(stderr,"main: unable to open the file");
      exit(EXIT_FAILURE);
    }
  
    fgets(buffer,buf_size,fp);
  
    //here i store each word in an array of strings when I encounter 
    //an unwanted char I save the word into the next element of the 
    //array    
    for(int i = 0; i &lt; strlen(buffer); i++) {    
  
      if((buffer[i] &gt;= 'a' &amp;&amp; buffer[i] &lt;= 'z') || (buffer[i] &gt;= 'A' &amp;&amp; buffer[i] &lt;= 'Z')) {
          a[j][c++] = buffer[i];  
      } else {
          j++;
          c = 0;
          continue;
      }
    }
  
    //this print is used only to see the words in the array of strings
    for(int i = 0; i &lt; 100; i++) 
      printf("%s  %d\n", a[i], i);
  
    fclose(fp);
    printf("\nData loaded\n");
  }
  
  //Here I pass the file_name from command line
  int main(int argc, char const *argv[]) {
    if(argc &lt; 2) {
      printf("Usage: ordered_array_main &lt;file_name&gt;\n");
      exit(EXIT_FAILURE);
    }
  
    load_array(argv[1]);
  
  }
  </code></pre>
  
  <p>I know that I should store only the necessary number and words and not 100 everytime, I want to think about that later on, right now I want to fix the issue with the empty words.</p>
  
  <p>Compilation and execution</p>
  
  <pre><code>gcc -o testloadfile testloadfile.c
  
  ./testloadfile "correctme.txt"
  </code></pre>