title: Is char and int interchangeable for function arguments in C?
body: <p>I wrote some code to verify a serial number is alpha numeric in C using <code>isalnum</code>.  I wrote the code assuming <code>isalnum</code> input is <code>char</code>.  Everything worked.  However, after reviewing the <code>isalnum</code> later, I see that it wants input as <code>int</code>.  Is my code okay the way it is should I change it?</p>
  
  <p>If I do need to change, what would be the proper way?  Should I just declare an int and set it to the char and pass that to <code>isalnum</code>?  Is this considered bad programming practice?</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdbool.h&gt;
  
  
  bool VerifySerialNumber( char *serialNumber ) { 
  int num;
  char* charPtr = serialNumber;
  
  
  if( strlen( serialNumber ) &lt; 10 ) { 
      printf("The entered serial number seems incorrect.");
      printf("It's less than 10 characters.\n");
      return false;
  }   
  
  while( *charPtr != '\0' ) { 
      if( !isalnum(*charPtr) ) { 
      return false;
      }   
      *charPtr++;
  }   
  return true;
  }
  
  
  int main() {
  char* str1 = "abcdABCD1234";
  char* str2 = "abcdef##";
  char* str3 = "abcdABCD1234$#";
  bool result;
  
  result = VerifySerialNumber( str1 );
  printf("str= %s, result=%d\n\n", str1, result);
  
  result = VerifySerialNumber( str2 );
  printf("str= %s, result=%d\n\n", str2, result);
  
  result = VerifySerialNumber( str3 );
  printf("str= %s, result=%d\n\n", str3, result);
  return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>str= abcdABCD1234, result=1
  
  The entered serial number seems incorrect.It's less than 10 characters.
  str= abcdef##, result=0
  
  str= abcdABCD1234$#, result=0
  </code></pre>