printf("buffer 2 is greater than buffer 1/n");
else
printf("buffer 2 is less than buffer 1/n");
ptr = strncmp(buf2,buf3,3);
if (ptr0)
printf("buffer 2 is greater than buffer 3/n");
else
printf("buffer 2 is less than buffer 3/n");
return(0);
}
函数名: strncmpi
功能: 把串中的一部分与另一串中的一部分比较, 不管大小写
用法: int strncmpi(char *str1, char *str2, int len);
举例:
[cpp] view plain copy
#include string.h
#include stdio.h
int main(void)
{
char *buf1 = "BBBccc", *buf2 = "bbbccc";
int ptr;
ptr = strncmpi(buf2,buf1,3);
if (ptr0)
printf("buffer 2 is greater than buffer 1/n");
if (ptr0)
printf("buffer 2 is less than buffer 1/n");
if (ptr == 0)
printf("buffer 2 equals buffer 1/n");
return 0;
}
函数名: strnset
功能: 将一个串中的所有字符都设为指定字符
用法: char *strnset(char *str, char ch, unsigned n);
举例:
[cpp] view plain copy
#include stdio.h
#include string.h
int main(void)
{
char *string = "abcdefghijklmnopqrstuvwxyz";
char letter = 'x';
printf("string before strnset: %s/n", string);
strnset(string, letter, 13);
printf("string afterstrnset: %s/n", string);
return 0;
}
函数名: strpbrk
功能: 在串中查找给定字符集中的字符
用法: char *strpbrk(char *str1, char *str2);
举例:
[cpp] view plain copy
#include stdio.h
#include string.h
int main(void)
{
char *string1 = "abcdefghijklmnopqrstuvwxyz";
char *string2 = "onm";
char *ptr;
ptr = strpbrk(string1, string2);
if (ptr)
printf("strpbrk found first character: %c/n", *ptr);
else
printf("strpbrk didn't find character in set/n");
return 0;
}
函数名: strrev
功能: 串倒转
用法: char *strrev(char *str);
举例:
[cpp] view plain copy
#include string.h
#include stdio.h
int main(void)
{
char *forward = "string";
printf("Before strrev(): %s/n", forward);
strrev(forward);
printf("After strrev():%s/n", forward);
return 0;
}
/*运行结果:
Before strrev(): string
After strrev():gnirts
*/
函数名: strstr
功能: 在串中查找指定字符串的第一次出现
用法: char *strstr(char *str1, char *str2);
举例:
[cpp] view plain copy
#include stdio.h
#include string.h
int main(void)
{
char *str1 = "Borland International", *str2 = "nation", *ptr;
ptr = strstr(str1, str2);
printf("The substring is: %s/n", ptr);
return 0;
}
函数名: strtod
功能: 将字符串转换为double型值
用法: double strtod(char *str, char **endptr);
举例:
[cpp] view plain copy
#include stdio.h
#include stdlib.h
int main(void)
{
char input[80], *endptr;
double value;
printf("Enter a floating point number:");
gets(input);
value = https://www.04ip.com/post/strtod(input, endptr);
printf("The string is %s the number is %lf/n", input, value);
return 0;
}
函数名: strtol
功能: 将串转换为长整数
用法: long strtol(char *str, char **endptr, int base);
举例:
[cpp] view plain copy
#include stdlib.h
#include stdio.h
int main(void)
{
char *string = "87654321", *endptr;
long lnumber;
/* strtol converts string to long integer*/
lnumber = strtol(string, endptr, 10);
printf("string = %slong = %ld/n", string, lnumber);
return 0;
}
函数名: strupr
功能: 将串中的小写字母转换为大写字母
推荐阅读
- 阿里云服务器外汇软件,阿里云外汇是什么
- 为什么c语言越难学,c语言为什么难以精通
- flutter云开发,flutter开源
- 直播网红美国,主播美国
- linux命令拼接 linux命令拼接执行
- 如何看待新媒体的利弊,如何看待新媒体未来发展
- mdb文件导入到oracle数据库,mdb导入excel数据
- 家装公司抖音如何推广,装修行业怎么在抖音打广告
- c语言函数的封装调用 c++函数封装和函数调用