1. 程式人生 > >c 判斷一個字符是否為字母數字

c 判斷一個字符是否為字母數字

pan ret %d div clu spa str 是否 main

#include <stdio.h>
#include <wctype.h>
int main ()
{
  int i;
  wchar_t str[] = L"c3po...";
  i=0;
  while (iswalnum(str[i])){ 
      i++;
  } 
  wprintf (L"The first %d characters are alphanumeric.\n",i);
  return 0;
}

輸出

The first 4 characters are alphanumeric.

c 判斷一個字符是否為字母數字