//-1:strtok()函数
#include<stdio.h>
#include<string.h>
int main(void)
{
char buf[]="hello#world#today";//即将被分割的字符串
char *temp = strtok(buf,"#");
while(temp)
{
printf("%s ",temp);
temp = strtok(NULL,"#");
}
printf("\n");
return 0;
}
//-2:strrchr()
#include <string.h>
#include <stdio.h>
void main()
{
char * pCh = "www.inkcool.com";
char * pFind = strrchr(pCh, '.');//找出点.最后一次出现在pCH的位置
if ( pFind != NULL)
{
printf("%s", pFind); //可以直接printf(pFind);printf("/n");左边的表达式是合二为一的表达方法;
}
printf("\n");
}
//-3:strpbrk():返回两个字符串中首个相同字符的位置
#include<stdio.h>
#include<string.h>
int main(void){
char* s1 = "http://see.xidian.edu.cn/cpp/u/xitong/";//在C语言中,用指针形式来定义未知长度的字符串
char* s2 = "see";
char* p = strpbrk(s1,s2);
if(p){
printf("The result is: %s\n",p);
}else{
//-4:strlen()返回字符串的长度
#include<stdio.h>
#include<string.h>
int main(void)
{
char* str1 = "zheng chaobing";
printf("strlen(str1)=%d",strlen(str1));
return 0;
}
printf("Sorry!\n"); } return 0; }