点击(此处)折叠或打开
- #include <stdio.h>
- #include <string.h>
- void strplus(char *s, char *t) {
- char *r, *malloc();
- r = malloc(strlen(s)+strlen(t)+1);
- strcpy(r,s);
- strcat(r,t);
- printf("%d, %d, %s\n",strlen(s),strlen(t),r);
- free(r);
- }
2. 反转字符串
点击(此处)折叠或打开
- #include <stdio.h>
- #include <string.h>
- void strv(char *s) {
- int i, x=strlen(s);
- char *r, *malloc();
- r=malloc(x+1);
- for (i=0;i<x;i++) r[i]=s[x-1-i];
- r[x]='\0';
- printf("the reversion of %s is %s .\n", s, r);
- free(r);
- }