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

c strchr函数_strchr函数php_strchr函数功能(4)

电脑杂谈  发布时间:2017-02-21 12:41:08  来源:网络整理

int main(void)

{

char string[15];

strchr函数功能_c strchr函数_strchr函数php

char *ptr, c = 'r';

strcpy(string, "This is a string");

ptr = strchr(string, c);

if (ptr)

printf("The character %c is at position: %d/n", c, ptr-string);

else

printf("The character was not found/n");

return 0;

}

7、函数名: strcspn

用 法: int strcspn(char *str1, char *str2);

功 能: 在第一个串中查找包含任何第二个串给定字符集内容的位置(Get span until character in string, Scans str1 for the first occurrence of any of the characters that are part of str2, returning the number of characters of str1 read before this first occurrence. The search includes the terminating null-characters, so the function will return the length of str1 if none of the characters of str2 are found in str1.)

程序例:

#include <stdio.h>

#include <string.h>

#include <alloc.h>

int main(void)

{

char *string1 = "1234567890";

char *string2 = "747D18";

int length;

length = strcspn(string1, string2); //length=0, match letter is 1

printf("Character where strings intersect is at position %d/n", length);

return 0;

}

8、函数名: strspn

用 法: int strspn(char *str1, char *str2);

功 能: 在串中查找指定字符集出现在串的子集的长度(Get span of character set in string, Returns the length of the initial portion of str1 which consists only of characters that are part of str2)

程序例:

#include <stdio.h>

#include <string.h>

#include <alloc.h>

int main(void)

{

char *string1 = "1234567890";

char *string2 = "23DC81";

int length;

length = strspn(string1, string2); //length=3, the initial portion '123' cnsists of characters that are pare of string2


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

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

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