`

字符串拼接,分割

 
阅读更多

#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;
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics