av手机免费在线观看,国产女人在线视频,国产xxxx免费,捆绑调教一二三区,97影院最新理论片,色之久久综合,国产精品日韩欧美一区二区三区

C語言

C語言中isalnum()函數和isalpha()函數的對比

時間:2025-03-14 02:31:29 C語言 我要投稿
  • 相關推薦

C語言中isalnum()函數和isalpha()函數的對比

  C語言isalnum()函數:判斷字符是否為英文字母或數字

  頭文件:

  #include

  isalnum() 用來判斷一個字符是否為英文字母或數字,相當于 isalpha(c) || isdigit(c),其原型為:

  int isalnum(int c);

  【參數】c 為需要檢測的字符。

  【返回值】若參數c 為字母或數字,若 c 為 0 ~ 9 a ~ z A ~ Z 則返回非 0,否則返回 0。

  注意,isalnum()為宏定義,非真正函數。

  【實例】找出str 字符串中為英文字母或數字的字符。

  #includemain(){ char str[] = "123c@#FDsP[e"; int i; for (i = 0; str[i] != 0; i++) if(isalnum(str[i])) printf("%c is an alphanumeric charactern", str[i]);}

  輸出結果:

  1 is an apphabetic character2 is an apphabetic character3 is an apphabetic characterc is an apphabetic characterF is an apphabetic characterD is an apphabetic characters is an apphabetic characterP is an apphabetic charactere is an apphabetic character

  C語言isalpha()函數:判斷字符是否為英文字母

  頭文件:

  #include

  isalpha() 用來判斷一個字符是否是英文字母,相當于 isupper(c)||islower(c),其原型為:

  int isalpha(int c);

  【參數】c 為需要被檢測的字符。

  【返回值】若參數c 為英文字母(a ~ z A ~ Z),則返回非 0 值,否則返回 0。

  注意,isalpha() 為宏定義,非真正函數。

  【實例】找出str 字符串中為英文字母的字符。

  #includemain(){ char str[] = "123c@#FDsP[e"; int i; for (i = 0; str[i] != 0; i++) if(isalpha(str[i])) printf("%c is an alphanumeric charactern", str[i]);}

  執(zhí)行結果:

  c is an apphabetic characterF is an apphabetic characterD is an apphabetic characters is an apphabetic characterP is an apphabetic charactere is an apphabetic character

【C語言中isalnum()函數和isalpha()函數的對比】相關文章:

C語言中函數的區(qū)分08-30

C語言中malloc()和free()函數的理解10-24

C語言中gets()函數知識08-10

C語言中關于時間的函數10-24

C語言中strpbr()函數的用法07-25

c語言中time函數的用法08-27

C語言中指針函數與函數指針有何區(qū)別09-28

C語言中Swift函數調用實例09-25

C語言中編寫可變參數函數09-28