首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

字符串拼凑,分割

2012-06-28 
字符串拼接,分割#includestdio.h#includestdlib.h#includestring.h#define BUFFER_SIZE 64int main(

字符串拼接,分割

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define BUFFER_SIZE 64
int main(){
char s[BUFFER_SIZE]="orld";
char d[BUFFER_SIZE]="Hello W";
//strcat,字符串拼接
strcat(d,s);
printf("%s\n",s);
printf("%s\n",d);
//strncat,字符串拼接
strncat(d,s,3);
printf("%s\n",d);
//strtok,字符串分割
char str[]="Linux C Programming";
char *p;
p=strtok(str," ");
while(p!=NULL){
printf("%s\n",p);
p=strtok(NULL," ");
}
printf("str:%s\n",str);
return 0;
}

热点排行