您的位置:首页 > 健康 > 养生 > 建站快车凡科_网页制作基础教程教案_seo实战培训教程_武汉百度推广公司

建站快车凡科_网页制作基础教程教案_seo实战培训教程_武汉百度推广公司

2024/10/6 8:33:52 来源:https://blog.csdn.net/qq_53139964/article/details/142364030  浏览:    关键词:建站快车凡科_网页制作基础教程教案_seo实战培训教程_武汉百度推广公司
建站快车凡科_网页制作基础教程教案_seo实战培训教程_武汉百度推广公司

目录

1 isdigit()

1.1 函数原型

1.2 功能说明

1.3 代码示例

2 isxdigit()

2.1 函数原型

2.2 功能说明

2.3 代码示例

3 islower()

3.1 函数原型

3.2 功能说明

3.3 代码示例

4 isupper()

4.1 函数原型

4.2 功能说明

4.3 代码示例

5 isalnum()

5.1 函数原型

5.2 功能说明

5.3 代码示例

6 isalpha()

6.1 函数原型

6.2 功能说明

6.3 代码示例

7 isascii()

7.1 函数原型

7.2 功能说明

7.3 代码示例

8 iscntrl()

8.1 函数原型

8.2 功能说明

8.3 代码示例

9 isgraph()

9.1 函数原型

9.2 功能说明

9.3 代码示例

10 isprint()

10.1 函数原型

10.2 功能说明

10.3 代码示例

11 ispunct()

11.1 函数原型

11.2 功能说明

11.3 代码示例

12 isspace()

12.1 函数原型

12.2 功能说明

12.3 代码示例

13 toascii()

13.1 函数原型

13.2 功能说明

13.3 代码示例

14 tolower()

14.1 函数原型

14.2 功能说明

14.3 代码示例

15 toupper()

15.1 函数原型

15.2 功能说明

15.3 代码示例

16 速览表


1 isdigit()

1.1 函数原型

#include <ctype.h>
int isdigit(int c);

1.2 功能说明

功能:

  • 检查参数 c 是否是数字。

返回值:

  • 如果 c 是数字('0' - '9'),返回非零值(真)。
  • 如果 c 不是数字,返回 0(假)。

ASCII 码范围:

  • 数字('0' - '9'),对应的 ASCII 码值为 48 到 57

1.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 isdigit 函数int main()
{char str[] = "Hello, World! 12345@#$";int i = 0;// 遍历字符串while (str[i] != '\0'){// 如果当前字符是数字if (isdigit(str[i])){printf("%c ", str[i]);// 1 2 3 4 5}i++;}return 0;
}

2 isxdigit()

2.1 函数原型

#include <ctype.h>
int isxdigit(int c);

2.2 功能说明

功能:

  • 检查参数 c 是否是十六进制数字字符。

返回值:

  • 如果 c 是十六进制数字('0' - '9'、'a' - 'f'、'A' - 'F')字符,返回非零值(真)。
  • 如果 c 不是十六进制数字字符,返回 0(假)。

ASCII 码范围:

  • 数字('0' - '9'),对应的 ASCII 码值为 48 到 57。
  • 小写字母('a' - 'f'),对应的 ASCII 码值为 97 到 102。
  • 大写字母('A' - 'F'),对应的 ASCII 码值为 65 到 70。

2.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 isxdigit 函数int main()
{char str[] = "Hello, World! 12345ABCDEFabcdef@#$";int i = 0;// 遍历字符串while (str[i] != '\0'){// 如果当前字符是十六进制数字if (isxdigit(str[i])){printf("%c ", str[i]);// e d 1 2 3 4 5 A B C D E F a b c d e f}i++;}return 0;
}

3 islower()

3.1 函数原型

#include <ctype.h>
int islower(int c);

3.2 功能说明

功能:

  • 检查参数 c 是否是小写字母。

返回值:

  • 如果 c 是小写字母('a' - 'z'),返回非零值(真)。
  • 如果 c 不是小写字母,返回 0(假)。

ASCII 码范围:

  • 小写字母('a' - 'z'),对应的 ASCII 码值为 97 到 122。

3.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 islower 函数int main()
{char str[] = "Hello, World! 12345@#$";int i = 0;// 遍历字符串while (str[i] != '\0'){// 如果当前字符是小写字母if (islower(str[i])){printf("%c ", str[i]);// e l l o o r l d}i++;}return 0;
}

4 isupper()

4.1 函数原型

#include <ctype.h>
int isupper(int c);

4.2 功能说明

功能:

  • 检查参数 c 是否是大写字母。

返回值:

  • 如果 c 是大写字母('A' - 'Z'),返回非零值(真)。
  • 如果 c 不是大写字母,返回 0(假)。

ASCII 码范围:

  • 大写字母('A' - 'Z'),对应的 ASCII 码值为 65 到 90。

4.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 isupper 函数int main()
{char str[] = "Hello, World! 12345@#$";int i = 0;// 遍历字符串while (str[i] != '\0'){// 如果当前字符是大写字母if (isupper(str[i])){printf("%c ", str[i]);// H W}i++;}return 0;
}

5 isalnum()

5.1 函数原型

#include <ctype.h>  
int isalnum(int c);

5.2 功能说明

功能:

  • 检查参数 c 是否是字母(大写或小写)或数字。

返回值:

  • 如果 c 是字母(大写或小写)或数字,返回非零值(真)。
  • 如果 c 不是字母或数字,返回 0(假)。

ASCII 码范围:

  • 字母(A - Z, a - z)
  • 数字(0 - 9)

5.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 isalnum 函数int main()
{char str[] = "Hello, World! 123@#$";int i = 0;// 遍历字符串while (str[i] != '\0'){// 如果当前字符是字母或数字if (isalnum(str[i])){printf("%c ", str[i]);// H e l l o W o r l d 1 2 3}i++;}return 0;
}

6 isalpha()

6.1 函数原型

#include <ctype.h>  
int isalpha(int c);

6.2 功能说明

功能:

  • 检查参数 c 是否是字母(大写或小写)。

返回值:

  • 如果 c 是字母(大写或小写),返回非零值(真)。
  • 如果 c 不是字母,返回 0(假)。

ASCII 码范围:

  • 字母(A - Z, a - z)

6.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 isalpha 函数int main()
{char str[] = "Hello, World! 123@#$";int i = 0;// 遍历字符串while (str[i] != '\0'){// 如果当前字符是字母if (isalpha(str[i])){printf("%c ", str[i]);// H e l l o W o r l d}i++;}return 0;
}

7 isascii()

7.1 函数原型

#include <ctype.h>
int isascii(int c);

7.2 功能说明

功能:

  • 检查参数 c 是否是 ASCII 字符。

返回值:

  • 如果 c 是 ASCII 字符(即 c 在 0 到 127 之间),返回非零值(真)。
  • 如果 c 不是 ASCII 字符,返回 0(假)。

ASCII 码范围:

  • ASCII 码值在 0 到 127 之间。

7.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 isascii 函数int main()
{char str[] = "Hello, 世界! 12345@#$";int i = 0;// 遍历字符串while (str[i] != '\0'){// 如果当前字符是 ASCII 字符if (isascii(str[i])){printf("%c ", str[i]);// H e l l o ,   !   1 2 3 4 5 @ # $}i++;}return 0;
}

8 iscntrl()

8.1 函数原型

#include <ctype.h>  
int iscntrl(int c);

8.2 功能说明

功能:

  • 检查参数 c 是否是控制字符。控制字符通常是不可打印的字符。

返回值:

  • 如果 c 是控制字符,返回非零值(真)。
  • 如果 c 不是控制字符,返回 0(假)。

ASCII 码范围:

  • ASCII 码值在 0 到 31 之间,加上 127(DEL)。

8.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 iscntrl 函数int main()
{char str[] = "Hello, World!\t\n\x1b[31mRed Text\x1b[0m";int i = 0;// 遍历字符串while (str[i] != '\0'){// 如果当前字符是控制字符if (iscntrl(str[i])){printf("Control character at position %d: '\\x%02x'\n", i, str[i]);}i++;}return 0;
}

        输出结果如下所示:

提示:

\\x%02x:

  • \\:这是一个转义序列,表示一个反斜杠字符 \。在字符串中,单个反斜杠 \ 通常用于转义特殊字符,所以要输出一个实际的反斜杠,需要使用 \\。
  • x:这是一个普通的字符 x,直接输出为 x。
  • %02x:
    • %:格式说明符的起始标志。
    • 02:指定输出的宽度为 2 位,不足 2 位时用前导零填充
    • x:指定输出为小写的十六进制数

ASCII 码:

        \t(制表符)的 ASCII 码值为 9。
        \n(换行符)的 ASCII 码值为 10。
        \x1b(ESC 控制字符)的 ASCII 码值为 27。


9 isgraph()

9.1 函数原型

#include <ctype.h>
int isgraph(int c);

9.2 功能说明

功能:

  • 检查参数 c 是否是可打印字符且不是空格。

返回值:

  • 如果 c 是可打印字符且不是空格(即 c 在 33 到 126 之间),返回非零值(真)。
  • 如果 c 不是可打印字符或为空格,返回 0(假)。

ASCII 码范围:

  • 可打印字符且不是空格(33 到 126),包括字母、数字、标点符号等。

9.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 isgraph 函数int main()
{char str[] = "Hello, World! 12345@#$ ";int i = 0;// 遍历字符串while (str[i] != '\0'){// 如果当前字符是可打印字符且不是空格if (isgraph(str[i])){printf("%c ", str[i]);// H e l l o , W o r l d ! 1 2 3 4 5 @ # $(无空格打印)}i++;}return 0;
}

10 isprint()

10.1 函数原型

#include <ctype.h>
int isprint(int c);

10.2 功能说明

功能:

  • 检查参数 c 是否是可打印字符(包括空格)。

返回值:

  • 如果 c 是可打印字符(即 c 在 32 到 126 之间),返回非零值(真)。
  • 如果 c 不是可打印字符,返回 0(假)。

ASCII 码范围:

  • 可打印字符(32 到 126),包括字母、数字、标点符号和空格。

10.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 isprint 函数int main()
{char str[] = "Hello, World! 12345@#$\t\n";int i = 0;// 遍历字符串while (str[i] != '\0'){// 如果当前字符是可打印字符if (isprint(str[i])){printf("%c ", str[i]);// H e l l o ,   W o r l d !   1 2 3 4 5 @ # $(有空格打印)}i++;}return 0;
}

11 ispunct()

11.1 函数原型

#include <ctype.h>
int ispunct(int c);

11.2 功能说明

功能:

  • 检查参数 c 是否是标点符号。

返回值:

  • 如果 c 是标点符号(即 c 在 33 到 47、58 到 64、91 到 96、123 到 126 之间),返回非零值(真)。
  • 如果 c 不是标点符号,返回 0(假)。

标点符号的 ASCII 码值范围包括:

  • 33 到 47:!、"、#、$、%、&、'、(、)、*、+、,、-、.、/
  • 58 到 64::、;、<、=、>、?、@
  • 91 到 96:[、\、]、^、_、``
  • 123 到 126:{、|、}、~

11.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 ispunct 函数int main()
{char str[] = "Hello, World! 12345@#$";int i = 0;// 遍历字符串while (str[i] != '\0'){// 如果当前字符是标点符号if (ispunct(str[i])){printf("%c ", str[i]);// , ! @ # $}i++;}return 0;
}

12 isspace()

12.1 函数原型

#include <ctype.h>
int isspace(int c);

12.2 功能说明

功能:

  • 检查参数 c 是否是空白字符。

返回值:

  • 如果 c 是空白字符,返回非零值(真)。
  • 如果 c 不是空白字符,返回 0(假)。

空白字符的 ASCII 码范围:

  • 空格( ):ASCII 码值 32
  • 水平制表符(\t):ASCII 码值 9
  • 新行符(\n):ASCII 码值 10
  • 垂直制表符(\v):ASCII 码值 11
  • 换页符(\f):ASCII 码值 12
  • 回车符(\r):ASCII 码值 13

12.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 isspace 函数int main()
{char str[] = "Hello, World! \t\n\r\f\v";int i = 0;// 遍历字符串while (str[i] != '\0'){// 如果当前字符是空白字符if (isspace(str[i])){printf("%d - %c\n", i, str[i]);// 6 -// 13 -// 14 -// 15 -// 16 -// 17 -// 18 -}i++;}return 0;
}

13 toascii()

13.1 函数原型

#include <ctype.h>
int toascii(int c);

13.2 功能说明

功能:

  • 将参数 c 转换为对应的 ASCII 字符。

返回值:

  • 返回 c 的低 7 位(即 c & 0x7F),确保结果在 0 到 127 之间。

用途:

  • 用于将多字节字符或扩展 ASCII 字符转换为标准的 7 位 ASCII 字符。

13.3 代码示例

#include <stdio.h>
#include <ctype.h> // 引入 toascii 函数int main()
{char str[] = "12345@#$";int i = 0;// 遍历字符串while (str[i] != '\0'){// 将字符转换为 ASCII 字符int ascii_char = toascii(str[i]);printf("Original: %c, ASCII: %c (Code: %d)\n", str[i], ascii_char, ascii_char);// Original: 1, ASCII: 1 (Code: 49)// Original: 2, ASCII: 2 (Code: 50)// Original: 3, ASCII: 3 (Code: 51)// Original: 4, ASCII: 4 (Code: 52)// Original: 5, ASCII: 5 (Code: 53)// Original: @, ASCII: @ (Code: 64)// Original: #, ASCII: # (Code: 35)// Original: $, ASCII: $ (Code: 36)i++;}return 0;
}

14 tolower()

14.1 函数原型

#include <ctype.h>
int tolower(int c);

14.2 功能说明

功能:

  • 将参数 c 转换为对应的小写字母。

返回值:

  • 如果 c 是大写字母('A' - 'Z'),返回其对应的小写字母('a' - 'z')。
  • 如果 c 已经是小写字母或不是字母,返回 c 本身。

ASCII 码范围:

  • 大写字母('A' - 'Z'),对应的 ASCII 码值为 65 到 90。
  • 小写字母('a' - 'z'),对应的 ASCII 码值为 97 到 122。

14.3 代码示例

#include <stdio.h>
#include <ctype.h>  // 引入 tolower 函数int main()
{char str[] = "Hello, World! 12345@#$";int i = 0;// 遍历字符串while (str[i] != '\0'){// 将字符转换为小写str[i] = tolower(str[i]);i++;}// 输出转换后的字符串printf("Lowercase string: %s\n", str);// Lowercase string: hello, world! 12345@#$return 0;
}

15 toupper()

15.1 函数原型

#include <ctype.h>
int toupper(int c);

15.2 功能说明

功能:

  • 将参数 c 转换为对应的大写字母。

返回值:

  • 如果 c 是小写字母('a' - 'z'),返回其对应的大写字母('A' - 'Z')。
  • 如果 c 已经是大写字母或不是字母,返回 c 本身。

ASCII 码范围:

  • 小写字母('a' - 'z'),对应的 ASCII 码值为 97 到 122。
  • 大写字母('A' - 'Z'),对应的 ASCII 码值为 65 到 90。

15.3 代码示例

#include <stdio.h>
#include <ctype.h>  // 引入 toupper 函数
#include <string.h> // 引入 strlen 函数int main()
{char str[] = "Hello, World! 12345@#$";int i = 0;// 遍历字符串while (str[i] != '\0'){// 将字符转换为大写str[i] = toupper(str[i]);i++;}// 输出转换后的字符串printf("Uppercase string: %s\n", str);// Uppercase string: HELLO, WORLD! 12345@#$return 0;
}

16 速览表

函数原型功能说明返回值
int isdigit(int c);检查参数 c 是否是数字。如果 c 是数字('0' - '9'),返回非零值(真)。
如果 c 不是数字,返回 0(假)。
int isxdigit(int c);检查参数 c 是否是十六进制数字字符。如果 c 是十六进制数字('0' - '9'、'a' - 'f'、'A' - 'F')字符,返回非零值(真)。
如果 c 不是十六进制数字字符,返回 0(假)。
int islower(int c);检查参数 c 是否是小写字母。如果 c 是小写字母('a' - 'z'),返回非零值(真)。
如果 c 不是小写字母,返回 0(假)。
int isupper(int c);检查参数 c 是否是大写字母。如果 c 是大写字母('A' - 'Z'),返回非零值(真)。
如果 c 不是大写字母,返回 0(假)。
int isalnum(int c);

检查参数 c 是否是字母(大写或小写)或数字。

如果 c 是字母(大写或小写)或数字,返回非零值(真)。
如果 c 不是字母或数字,返回 0(假)。
int isalpha(int c);检查参数 c 是否是字母(大写或小写)。如果 c 是字母(大写或小写),返回非零值(真)。
如果 c 不是字母,返回 0(假)。
int isascii(int c);检查参数 c 是否是 ASCII 字符。

如果 c 是 ASCII 字符(即 c 在 0 到 127 之间),返回非零值(真)。
如果 c 不是 ASCII 字符,返回 0(假)。

int iscntrl(int c);检查参数 c 是否是控制字符。控制字符通常是不可打印的字符。

如果 c 是控制字符,返回非零值(真)。
如果 c 不是控制字符,返回 0(假)。

int isgraph(int c);检查参数 c 是否是可打印字符且不是空格。如果 c 是可打印字符且不是空格(即 c 在 33 到 126 之间),返回非零值(真)。
如果 c 不是可打印字符或为空格,返回 0(假)。
int isprint(int c);检查参数 c 是否是可打印字符(包括空格)。如果 c 是可打印字符(即 c 在 32 到 126 之间),返回非零值(真)。
如果 c 不是可打印字符,返回 0(假)。
int ispunct(int c);检查参数 c 是否是标点符号。如果 c 是标点符号(即 c 在 33 到 47、58 到 64、91 到 96、123 到 126 之间),返回非零值(真)。
如果 c 不是标点符号,返回 0(假)。
int isspace(int c);检查参数 c 是否是空白字符(空格、制表、换行、换页等)。如果 c 是空白字符,返回非零值(真)。
如果 c 不是空白字符,返回 0(假)。
int toascii(int c);将参数 c 转换为对应的 ASCII 字符。返回 c 的低 7 位(即 c & 0x7F),确保结果在 0 到 127 之间。
int tolower(int c);将参数 c 转换为对应的小写字母。如果 c 是大写字母('A' - 'Z'),返回其对应的小写字母('a' - 'z')。
如果 c 已经是小写字母或不是字母,返回 c 本身。
int toupper(int c);将参数 c 转换为对应的大写字母。

如果 c 是小写字母('a' - 'z'),返回其对应的大写字母('A' - 'Z')。
如果 c 已经是大写字母或不是字母,返回 c 本身。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com