c语言函数用法大全

c语言函数用法大全

ID:34328148

大小:54.00 KB

页数:24页

时间:2019-03-05

c语言函数用法大全_第1页
c语言函数用法大全_第2页
c语言函数用法大全_第3页
c语言函数用法大全_第4页
c语言函数用法大全_第5页
资源描述:

《c语言函数用法大全》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、--函数名:stpcpy功 能:拷贝一个字符串到另一个用 法:char*stpcpy(char*destin,char*source);程序例:#include#includeintmain(void){  charstring[10];  char*str1="abcdefghi";  stpcpy(string,str1);  printf("%s",string);  return0;}   函数名:strcat功 能:字符串拼接函数用 法:char*strcat(char*destin,char*source);程序例:----#includ

2、e#includeintmain(void){  chardestination[25];  char*blank="",*c="C++",*Borland="Borland";  strcpy(destination,Borland);  strcat(destination,blank);  strcat(destination,c);  printf("%s",destination);  return0;}   函数名:strchr功 能:在一个串中查找给定字符的第一个匹配之处用 法:char*strchr(char*str,charc);

3、程序例:#include#include----intmain(void) {   charstring[15];   char*ptr,c='r';   strcpy(string,"Thisisastring");   ptr=strchr(string,c);   if(ptr)      printf("Thecharacter%cisatposition:%d",c,ptr-string);   else      printf("Thecharacterwasnotfound");   return0; }   函数名:strcmp功

4、 能:串比较用 法:intstrcmp(char*str1,char*str2);看Asic码,str1>str2,返回值>0;两串相等,返回0程序例:#include#include----intmain(void) {   char*buf1="aaa",*buf2="bbb",*buf3="ccc";   intptr;   ptr=strcmp(buf2,buf1);   if(ptr>0)      printf("buffer2isgreaterthanbuffer1");   else      printf("buffer2isles

5、sthanbuffer1");   ptr=strcmp(buf2,buf3);   if(ptr>0)      printf("buffer2isgreaterthanbuffer3");   else      printf("buffer2islessthanbuffer3");   return0; }   函数名:strncmpi功 能:将一个串中的一部分与另一个串比较,不管大小写用 法:intstrncmpi(char*str1,char*str2,unsignedmaxlen);程序例:----#include#include

6、intmain(void){  char*buf1="BBB",*buf2="bbb";  intptr;  ptr=strcmpi(buf2,buf1);  if(ptr>0)     printf("buffer2isgreaterthanbuffer1");  if(ptr<0)     printf("buffer2islessthanbuffer1");  if(ptr==0)     printf("buffer2equalsbuffer1");  return0;}   函数名:strcpy功 能:串拷贝----用 法:char*strcpy(char*str1,c

7、har*str2);程序例:#include#includeintmain(void) {   charstring[10];   char*str1="abcdefghi";   strcpy(string,str1);   printf("%s",string);   return0; }   函数名:strcspn功 能:在串中查找第一个给定字符集内容的段用 法

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。