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

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

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

void * memmove ( void * destination, const void * source, size_t num );

Part 2: Concatenation

3、函数名: strcat

功 能: 字符串拼接函数

用 法: char *strcat(char *destin, char *source);

程序例:

#include <string.h>

#include <stdio.h>

int main(void)

{

char destination[25];

char *blank = " ", *c = "C++", *Borland = "Borland";

strcpy(destination, Borland);

strcat(destination, blank);

strcat(destination, c);

printf("%s/n", destination);

return 0;

}

另外参考:

char * strncat ( char * destination, char * source, size_t num );

Part 3: Comparison

4、函数名: strcmp

功 能: 串比较,大小写敏感

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

比较ASCII码,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 1/n");

else

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

ptr = strcmp(buf2, buf3);

if (ptr > 0)

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

else

strchr函数功能_strchr函数php_c strchr函数

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

return 0;

}

4.1、函数名: stricmp(还有一种写法是strcmpi,VC 6.0都支持)

功 能: 以大小写不敏感方式比较两个串

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

程序例:

#include <string.h>

#include <stdio.h>

int main(void)

{

char *buf1 = "BBB", *buf2 = "bbb";

int ptr;

ptr = stricmp(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;


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

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

    • 罗立源
      罗立源

      今天依旧是你的颜狗#全员即刻加速1128迈##易烊千玺#

    • 狄焕
      狄焕

      明白

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