<ctype.h>测试
2012-09-02 11:20
309 查看
/*Tesing code for <ctype.h>*/ #include<stdio.h> #include<ctype.h> void create(char *); void testing(char *); void test_isalnum(char *); void test_isalpha(char *); void test_iscntrl(char *); void test_isdigit(char *); void test_isgraph(char *); void test_islower(char *); void test_isprint(char *); void test_ispunct(char *); void test_isspace(char *); void test_isupper(char *); void test_isxdigit(char *); void test_tolower(char *); void test_toupper(char *); int main() { char str[257]; create(str); testing(str); } void create(char *str) { int i; for(i = 0; i < 256; i++) str[i] = i; } void testing(char *str) { test_isalnum(str); test_isalpha(str); test_iscntrl(str); test_isdigit(str); test_isgraph(str); test_islower(str); test_isprint(str); test_ispunct(str); test_isspace(str); test_isupper(str); test_isxdigit(str); test_tolower(str); test_toupper(str); } void test_isalnum(char *str) /*字母或者数字*/ { int i; printf("Now testing function isalnum:\n"); for(i = 0; i < 256; i++) if(isalnum(str[i])) printf("%c ", str[i]); printf("\nEnd testing\n"); getch(); } void test_isalpha(char *str) /*字母*/ { int i; printf("Now testing function isalpha:\n"); for(i = 0; i < 256; i++) if(isalpha(str[i])) printf("%c ", str[i]); printf("\nEnd testing\n"); getch(); } void test_iscntrl(char *str) /*控制字符*/ { int i; printf("Now testing function iscntrl:\n"); for(i = 0; i < 256; i++) if(iscntrl(str[i])) printf("%c ", str[i]); printf("\nEnd testing\n"); getch(); } void test_isdigit(char *str) /*数字*/ { int i; printf("Now testing function isdigit:\n"); for(i = 0; i < 256; i++) if(isdigit(str[i])) printf("%c ", str[i]); printf("\nEnd testing\n"); getch(); } void test_isgraph(char *str) /*除空格以外的打印字符*/ { int i; printf("Now testing function isgraph:\n"); for(i = 0; i < 256; i++) if(isgraph(str[i])) printf("%c ", str[i]); printf("\nEnd testing\n"); getch(); } void test_islower(char *str) /*小写*/ { int i; printf("Now testing function islower:\n"); for(i = 0; i < 256; i++) if(islower(str[i])) printf("%c ", str[i]); printf("\nEnd testing\n"); getch(); } void test_isprint(char *str) /*打印字符*/ { int i; printf("Now testing function isprint:\n"); for(i = 0; i < 256; i++) if(isprint(str[i])) printf("%c ", str[i]); printf("\nEnd testing\n"); getch(); } void test_ispunct(char *str) /*除空格,字母,数字以外的打印字符*/ { int i; printf("Now testing function ispunct:\n"); for(i = 0; i < 256; i++) if(ispunct(str[i])) printf("%c ", str[i]); printf("\nEnd testing\n"); getch(); } void test_isspace(char *str) /*空白字符*/ { int i; printf("Now testing function isspace:\n"); for(i = 0; i < 256; i++) if(isspace(str[i])) printf("%d %c ", str[i], str[i]); printf("\nEnd testing\n"); getch(); } void test_isupper(char *str) /*大写*/ { int i; printf("Now testing function isupper:\n"); for(i = 0; i < 256; i++) if(isupper(str[i])) printf("%c ", str[i]); printf("\nEnd testing\n"); getch(); } void test_isxdigit(char *str) /*16进字符*/ { int i; printf("Now testing function isxdigit:\n"); for(i = 0; i < 256; i++) if(isxdigit(str[i])) printf("%c ", str[i]); printf("\nEnd testing\n"); getch(); } void test_tolower(char *str) /*大写变小写*/ { int i; printf("Now testing function tolower:\n"); printf("Before:\n"); for(i = 0; i < 256; i++) if(isupper(str[i])) printf("%c ", str[i]); printf("\n"); printf("After:\n"); for(i = 0; i < 256; i++) if(isupper(str[i])) printf("%c ", tolower(str[i])); printf("\nEnd testing\n"); getch(); } void test_toupper(char *str) /*小写变大写*/ { int i; printf("Now testing function toupper:\n"); printf("Before:\n"); for(i = 0; i < 256; i++) if(islower(str[i])) printf("%c ", str[i]); printf("\n"); printf("After:\n"); for(i = 0; i < 256; i++) if(islower(str[i])) printf("%c ", toupper(str[i])); printf("\nEnd testing\n"); getch(); }
相关文章推荐
- <ctype.h> 字符测试函数:字符大小转换函数
- TestLink1.9.3测试用例:Excel转换XML工具<一>
- 《C标准库》——之<ctype.h>
- 黑马程序员_关于黑马java班入学测试技术分享<前5题>(一)
- 【吐槽篇之经验<三>】性能问题定位与调优测试总结
- toupper <ctype.h> <cctype>
- 关于<不能成为专业软件测试人员的10大理由>的一些阐述
- Android初学笔记之<使用真机进行测试Android工程>
- 错误的程序之阶乘之和测试程序的快慢程度(加一个计时器)<time.h>和clock()函数
- SharePoint 2013 列表关于大数据的测试<二>
- <ctype.h> 库函数
- php实现多语言链接的问题 <!--未测试-->
- <LeetCode OJ>Count and Say【38】(测试案例有错)
- 整理:<cctype>(<ctype.h>)
- C语言标准库(1)—#include<ctype.h>
- TestLink1.9.3测试用例:Excel转换XML工具<二>实现代码
- RT-Thread 学习笔记(十二)--- 开启基于RTGUI的LCD显示功能(2)<编译测试>
- RT-Thread 学习笔记(十三)--- 开启基于RTGUI的LCD显示功能(3)<触屏屏驱动移植和测试>
- 如果解决测试之痛<特别是单元、集成测试之痛>
- <2> ulua pblua环境搭建+测试