Chinaunix首页 | 论坛 | 博客
  • 博客访问: 76013
  • 博文数量: 18
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 228
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-15 16:53
文章分类
文章存档

2015年(4)

2014年(14)

我的朋友

分类: 嵌入式

2015-02-26 10:19:13

#include
#include
#include
#include
#include
#include




//char *strsep(char **stringp, const char *delim);
//??????·???×?·???????×é×?·?????
//??stringp???ò?????????ò?ó?¨?è??
//????delim???ò??×?·???????×?·??ó??
//????×?·???????NULL??·???stringp???ò?????·??
//
#if 1
void main()
{
char str[] = "abcdefcghdij";
char *p = str;
char *key_point;


key_point = strsep(&p, "cd");
printf("%s\n",key_point);//ab



key_point = strsep(&p, "cd");
printf("%s\n",key_point);//????·?



key_point = strsep(&p, "cd");
printf("%s\n",key_point);//ef



key_point = strsep(&p, "cd");
printf("%s\n",key_point);//gh


key_point = strsep(&p, "cd");
printf("%s\n",key_point);//ij
}
#endif


#if 1
//????2??·???×?·?????×??á:strsep·???????·????ó??????×?·????????????????????????????????ò·????ó?????à×?·??????ü??????·??????ü×???????×?·????????????????????????é????
/*
*????·???????a,b,c??????Jim,JACK??????·???
*/
void main()
{
char str[] = "Jim=88,Jack=89,Lily=86,Lucy=90,a=1,b=2,c=3,d=4,e=5,f=6,g=7";
char *name, *score,*next,*current;
int i;


current = str;


for(i=0; i<11; i++){
name = strsep(¤t,"=");//×??? = ??·??????ó??current????×????ò?ó??????????????=???ó????×?·?
printf("current = %s\n",current);


printf("name = %s\n",name);
// next = score;
score = strsep(¤t, ",");


printf("score = %s\n",score);
}


}
#endif


#if 3
//??????
//strtok????·¨


void main()
{
char token[] = "abdzxbcdefgch";
printf("%s\n",token);
char *tokenremain = token;
char *tok1 = strtok(tokenremain, "cde");
printf("tok1 = %s\n",tok1); //tok1 = ab
//printf("tokenremain = %s\n",tokenremain);//×???tokenremain?????????ò?ó????????strsep????


tok1 = strtok(NULL,"cde");
printf("tok1 = %s\n",tok1);//tok1 = zxb
// printf("tokenremain = %s\n",tokenremain);


tok1 = strtok(NULL,"cde");
printf("tok1 = %s\n",tok1);//tok1 = fg
return ;
/*
*?ò??:
tok1 = ab
tok1 = zxb
tok1 = fg
???ò????????????????:strtok(tokenremain,"ced"),????"cde"????????????×?·??????ü±???\0
?????????±??×?·???????·???????????????×?·??????????ò?ó??????\0?ó????
????×?·?


×???·?????????????×?????×?·???????????????±???
*/




}


#endif

阅读(2431) | 评论(0) | 转发(0) |
0

上一篇:SOCKET地址参数API

下一篇:数组

给主人留下些什么吧!~~