b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

strchr函数php_c++ strchr函数_模拟实现strchr函数(7)

电脑杂谈  发布时间:2017-02-21 09:19:16  来源:网络整理

{ char string[15];char *ptr, c = 'r';strcpy(string, "This is a string");ptr = strchr(string, c);if (ptr)

printf("The character %c is at position: %dn", c, ptr-string);else printf("The character was not foundn");return 0;}

函数名: strcmp功 能: 串比较用 法: int strcmp(char *str1, char *str2);看Asic码,str1>str2,返回值 > 0;两串相等,返回0程序例:#include <string.h> #include <stdio.h> int main(void)

{ char *buf1 = "aaa", *buf2 = "bbb", *buf3 = "ccc";int ptr;ptr = strcmp(buf2, buf1);if (ptr > 0)

printf("buffer 2 is greater than buffer 1n");else printf("buffer 2 is less than buffer 1n");ptr = strcmp(buf2, buf3);if (ptr > 0)

printf("buffer 2 is greater than buffer 3n");else printf("buffer 2 is less than buffer 3n");return 0;}

函数名: strncmpi功 能: 将一个串中的一部分与另一个串比较, 不管大小写用 法: int strncmpi(char *str1, char *str2, unsigned maxlen);程序例:#include <string.h> #include <stdio.h> int main(void)

{ char *buf1 = "BBB", *buf2 = "bbb";int ptr;ptr = strcmpi(buf2, buf1);if (ptr > 0)

printf("buffer 2 is greater than buffer 1n");if (ptr < 0)

printf("buffer 2 is less than buffer 1n");if (ptr == 0)

printf("buffer 2 equals buffer 1n");return 0;}

函数名: strcpy功 能: 串拷贝用 法: char *strcpy(char *str1, char *str2);程序例:#include <stdio.h> #include <string.h> int main(void)

{ char string[10];char *str1 = "abcdefghi";strcpy(string, str1);printf("%sn", string);return 0;}

函数名: strcspn功 能: 在串中查找第一个给定字符集内容的段用 法: int strcspn(char *str1, char *str2);程序例:#include <stdio.h> #include <string.h> #include <alloc.h> int main(void)


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-33642-7.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...