title: How to check last character in command line arguements?
body: <p>So im trying to count the number of files in the command line, heres what ive got so far</p>
  
  <pre><code># include &lt;stdio.h&gt;
  # include &lt;stdlib.h&gt;
  
  int main(int argc, char* argv[]){
  int cCount = 0;
  int cHeadCount = 0;
  int objCount = 0; 
  int makeCount = 0;
  int othCount =0;
  
  for(int i = 1; i&lt; argc; i++){
      /*
      if argv[i] last char is c 
          cCount++;
  
      if argv[i] last char is h 
          cHeadCount++;
  
      and so on for the rest
  
      */
  printf("C Source: %d\n", cCount);
  printf("C Header: %d\n", cHeadCount);
  printf("Object: %d\n", objCount);
  printf("Make: %d\n", makeCount);
  printf("Other: %d\n", othCount);
  }
  </code></pre>
  
  <p>so if you type in something like <code>$ ./fm main.c main.o sub.c sub.o</code> you should get </p>
  
  <pre><code>C source: 2
  C header: 0
  Object: 2
  Make: 0
  Other: 0
  </code></pre>
  
  <p>What i need help is the <code>if</code> statements inside the for loop. BTW is the for loop correct? Is there a function that will return the last character of a string? From what Ive seen, I dont seem to recall one but I could be very wrong. </p>
  
  <p>If im going about this wrong, or on right track, please tell me. Any help appreciated. </p>
  
  <p>EDIT: </p>
  
  <p>Heres what I have inside the <code>for</code> loop: </p>
  
  <pre><code>for(int i = 1; i &lt; argc; i++){
      int len = strlen (argv[i]);
  
      if ((argv[i][len - 2] != '.') ){
          if((strcmp(argv[i], "Makefile")==0) || (strcmp(argv[i], "makefile")==0)){
          makeCount++;
      }else{
          othCount++;
          continue; //if i take this out, it counts `other` objects wrong too
      }
      }
  
      if(argv[i][len - 1] == 'c'){
          cCount++;
  
      }
  
      else if(argv[i][len - 1] == 'h'){
          cHeadCount++;
  
      }
  
      else if(argv[i][len - 1] == 'o'){
          objCount++;
  
      }
  
      else {
          othCount++;           
      }       
  
  }
  </code></pre>
  
  <p>So the problem now is that its not recognizing <code>makefile</code>s as a Makefile. It counting them as <code>Other</code>. So where I should have say 5 <code>Makefile</code>s and 10 <code>Other</code> files, its saying i have 0 <code>makefiles</code> and 15 <code>Other</code> files.  <code>c</code>, <code>h</code> and <code>o</code> files work/count fine. Any help appreciated </p>