没有合适的资源?快使用搜索试试~ 我知道了~
string函数
资源推荐
资源详情
资源评论
string.h
▪strcpy
▪strncpy
▪strcat
▪strchr
▪strcmp
▪strnicmp
▪strlen
▪strcspn
▪strdup
▪stricmp
▪strerror
▪strcmpi
▪strncmp
▪strncpy
▪strnicmp
▪strnset
▪strpbrk
▪strrchr
▪strrev
▪strset
▪strspn
▪strstr
▪strtod
▪strtok
▪strtol
▪strupr
▪swab
strcpy
函数名:strcpy
功 能: 拷贝一个字符串到另一个
用 法: char *strcpy(char *destin, char *source);
程序例:
#include <stdio.h>
#include <string.h>
int main(void)
char string[10];
char *str1 = "abcdefghi";
strcpy(string, str1);
printf("%s\n", string);
return 0;
strncpy
函数名:strncpy
原型:char *strncpy(char *dest, char *src,size_tn);
功能:将字符串 src 中最多 n 个字符复制到字符数组 dest 中(它并不像 strcpy 一样遇
到 NULL 才停止复制,而是等凑够 n 个字符才开始复制),返回指向 dest 的指针。
strcat
函数名:strcat
功 能: 字符串拼接函数
用 法: char *strcat(char *destin, char *source);
程序例:
#include <string.h>
#include <stdio.h>
void main()
{
char destination[25];
char *blank = " ", *c = "C++", *Borland = "Borland";
strcpy(destination, Borland);
strcat(destination, blank);
strcat(destination, c);
printf("%s\n", destination);
}
strchr
函数名:strchr
功 能: 在一个串中查找给定字符的第一个匹配之处\
用 法: char *strchr(char *str, char c);
程序例:
#include <string.h>
#include <stdio.h>
int main(void)
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: %d\n", c, ptr-string);
else
printf("The character was not found\n");
return 0;
strcmp
函数名: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 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
printf("buffer 2 is less than buffer 3\n");
return 0;
strnicmp
函数名:strnicmp
功 能: 将一个串中的一部分与另一个串比较, 不管大小写
用 法: intstrnicmp(char *str1, char *str2, unsigned maxlen);
程序例:
#include <string.h>
#include <stdio.h>
int main(void)
char *buf1 = "BBB", *buf2 = "bbb";
剩余12页未读,继续阅读
资源评论
蜡烛花
- 粉丝: 3
- 资源: 57
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于opencv的dnn模块实现Yolo-Fastest的目标检测python源码+模型+说明(高分项目).zip
- 使用Python调用微信本地ocr服务.zip
- 【精品推荐】人工智能在医疗中的应用.pptx
- 【精品推荐】电子医疗仪器人机接口-(1).ppt
- 【精品推荐】电子医疗仪器人机接口.ppt
- ubuntu镜像ubuntu镜像01
- 基于paddle搭建神经网络实现5种水果识别分类python源码+数据集(高分毕设).zip
- 【精品推荐】电子商务网店类型介绍.ppt
- 基于paddle搭建神经网络实现水果识别分类python源码+数据集(高分项目).zip
- 三菱plc编程口通信学习笔记.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功