C 递归调用Word文档格式.docx
- 文档编号:20490114
- 上传时间:2023-01-23
- 格式:DOCX
- 页数:14
- 大小:18.10KB
C 递归调用Word文档格式.docx
《C 递归调用Word文档格式.docx》由会员分享,可在线阅读,更多相关《C 递归调用Word文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
return0;
}
原型:
externchar*strstr(char*haystack,char*needle);
所在头文件:
功能:
从字符串haystack中寻找needle第一次出现的位置(不比较结束符NULL)。
说明:
返回指向第一次出现needle位置的指针,如果没找到则返回NULL。
具体使用例子:
Download:
strstr_sample.c
intmain(intargc,char**argv)
{
char*haystack="
aaa||a||bbb||c||ee||"
;
char*needle="
||"
char*buf=strstr(haystack,needle);
while(buf!
=NULL)
buf[0]='
\0'
printf("
%s\n"
haystack);
haystack=buf+strlen(needle);
buf=strstr(haystack,needle);
}
stpcpy
拷贝一个字符串到另一个
char*stpcpy(char*destin,char*source);
charstring[10];
abcdefghi"
stpcpy(string,str1);
%s\n"
string);
strcat
字符串拼接函数
char*strcat(char*destin,char*source);
chardestination[25];
char*blank="
"
*c="
C++"
*Borland="
Borland"
strcpy(destination,Borland);
strcat(destination,blank);
strcat(destination,c);
destination);
strchr
在一个串中查找给定字符的第一个匹配之处\
char*strchr(char*str,charc);
charstring[15];
char*ptr,c='
r'
strcpy(string,"
Thisisastring"
);
ptr=strchr(string,c);
if(ptr)
Thecharacter%cisatposition:
%d\n"
c,ptr-string);
else
Thecharacterwasnotfound\n"
strcmp
串比较
intstrcmp(char*str1,char*str2);
看Asic码,str1>
str2,返回值>
0;
两串相等,返回0
char*buf1="
aaa"
*buf2="
bbb"
*buf3="
ccc"
intptr;
ptr=strcmp(buf2,buf1);
if(ptr>
0)
buffer2isgreaterthanbuffer1\n"
buffer2islessthanbuffer1\n"
ptr=strcmp(buf2,buf3);
buffer2isgreaterthanbuffer3\n"
buffer2islessthanbuffer3\n"
return0;
strncmpi
将一个串中的一部分与另一个串比较,不管大小写
intstrncmpi(char*str1,char*str2,unsignedmaxlen);
BBB"
ptr=strcmpi(buf2,buf1);
if(ptr<
if(ptr==0)
buffer2equalsbuffer1\n"
strcpy
串拷贝
char*strcpy(char*str1,char*str2);
strcpy(string,str1);
strcspn
在串中查找第一个给定字符集内容的段
intstrcspn(char*str1,char*str2);
alloc.h>
char*string1="
1234567890"
char*string2="
747DC8"
intlength;
length=strcspn(string1,string2);
Characterwherestringsintersectisatposition%d\n"
length);
strdup
将串拷贝到新建的位置处
char*strdup(char*str);
char*dup_str,*string="
abcde"
dup_str=strdup(string);
dup_str);
free(dup_str);
stricmp
以大小写不敏感方式比较两个串
intstricmp(char*str1,char*str2);
ptr=stricmp(buf2,buf1);
strerror
返回指向错误信息字符串的指针
char*strerror(interrnum);
errno.h>
char*buffer;
buffer=strerror(errno);
Error:
buffer);
strcmpi
将一个串与另一个比较,不管大小写
intstrcmpi(char*str1,char*str2);
strncmp
intstrncmp(char*str1,char*str2,intmaxlen);
aaabbb"
bbbccc"
ptr=strncmp(buf2,buf1,3);
ptr=strncmp(buf2,buf3,3);
return(0);
把串中的一部分与另一串中的一部分比较,不管大小写
intstrncmpi(char*str1,char*str2);
BBBccc"
ptr=strncmpi(buf2,buf1,3);
strncpy
char*strncpy(char*destin,char*source,intmaxlen);
strncpy(string,str1,3);
string[3]='
strnicmp
不注重大小写地比较两个串
intstrnicmp(char*str1,char*str2,unsignedmaxlen);
ptr=strnicmp(buf2,buf1,3);
strnset
将一个串中的所有字符都设为指定字符
char*strnset(char*str,charch,unsignedn);
charstring[50]="
abcdefghijklmnopqrstuvwxyz"
charletter='
x'
stringbeforestrnset:
strnset(string,letter,13);
stringafterstrnset:
strpbrk
在串中查找给定字符集中的字符
char*strpbrk(char*str1,char*str2);
onm"
char*ptr;
ptr=strpbrk(string1,string2);
strpbrkfoundfirstcharacter:
%c\n"
*ptr);
strpbrkdidn'
tfindcharacterinset\n"
strrchr
在串中查找指定字符的最后一个出现
char*strrchr(char*str,charc);
strcpy(string,"
ptr=strrchr(string,c);
strrev
串倒转
char*strrev(char*str);
char*forward="
string"
Beforestrrev():
forward);
strrev(forward);
Afterstrrev():
strset
char*strset(char*str,charc);
charstring[10]="
123456789"
charsymbol='
c'
Beforestrset():
strset(string,symbol);
Afterstrset():
strspn
在串中查找指定字符集的子集的第一次出现
intstrspn(char*str1,char*str2);
123DC8"
length=strspn(string1,string2);
Characterwherestringsdifferisatposition%d\n"
strtod
将字符串转换为double型值
doublestrtod(char*str,char**endptr);
stdlib.h>
charinput[80],*endptr;
doublevalue;
Enterafloatingpointnumber:
"
gets(input);
value=strtod(input,&
endptr);
Thestringis%sthenumberis%lf\n"
input,value);
strtok
查找由在第二个串中指定的分界符分隔开的单词
char*strtok(char*str1,char*str2);
charinput[16]="
abc,d"
char*p;
p=strtok(input,"
"
if(p)
p);
p=strtok(NULL,"
strtol
将串转换为长整数
longstrtol(char*str,char**endptr,intbase);
char*string="
87654321"
*endptr;
longlnumber;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 递归调用 递归 调用