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

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

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

}

5、函数名: strncmp

功 能: 将一个串中的一部分与另一个串比较, 大小写敏感

用 法: int strncmp(char *str1, char *str2, size_t 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 1/n");

if (ptr < 0)

printf("buffer 2 is less than buffer 1/n");

if (ptr == 0)

printf("buffer 2 equals buffer 1/n");

return 0;

}

5.1、函数名: strncmpi(还有一种写法是strnicmp,VC 6.0都支持)

功 能: 把串中的一部分与另一串中的一部分比较, 不管大小写

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

程序例:

#include <string.h>

#include <stdio.h>

int main(void)

{

char *buf1 = "BBBccc", *buf2 = "bbbccc";

int ptr;

ptr = strncmpi(buf2,buf1,3);

if (ptr > 0)

printf("buffer 2 is greater than buffer 1/n");

if (ptr < 0)

printf("buffer 2 is less than buffer 1/n");

if (ptr == 0)

printf("buffer 2 equals buffer 1/n");

return 0;

}

其它参考:

int memcmp ( const void * ptr1, const void * ptr2, size_t num );

int strcoll ( const char * str1, const char * str2 );

size_t strxfrm ( char * destination, const char * source, size_t num );

Part 4: Searching

6、函数名: strchr

用 法: char *strchr(char *str, char c);

功 能: 在一个串中查找给定字符的第一个匹配之处(Locate first occurrence of character in string, Returns a pointer to the first occurrence of character in the C string str. The terminating null-character is considered part of the C string. Therefore, it can also be located to retrieve a pointer to the end of a string.)

程序例:

#include <string.h>

#include <stdio.h>


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

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

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