日本无码中文字幕片|日本精品在线观看无码视频|国产精品免费啪啪|Av无码一区二区|亚洲在线黄片免费观看|亚洲日韩中文字幕在线观看|熟女激情乱伦在线观看a黄片|成年人观看毛片网址|AV色色色色日韩性草|国产高清无码免费

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

時間:2025-07-29 15:31:22 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ū)分12-02

C語言中malloc()和free()函數的理解03-13

C語言中gets()函數知識01-23

C語言中關于時間的函數02-19

C語言中strpbr()函數的用法02-17

c語言中time函數的用法11-19

C語言中strstr()函數的使用分析11-10

C語言中Swift函數調用實例01-17

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