一,函数strcat(s,t)用指针的方式吧t指向的字符串复制到s指向的字符串的尾部
1.
#include <stdio.h>
#include <stdlib.h>
void strcat(char *s,char *t);
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
return 0;
}
void strcat(char *s,char *t){
while(*s!='\0'){
s++;
}
while((*s=*p)!='\0'){
p++;
s++;
}
}
2.
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void strcat(char *s,char *p);
int main(int argc, char *argv[]) {
return 0;
}
void strcat(char *s,char *p){
while(*s){
s++;
}
while(*s++=*t++){
}
}
2.数组
#include <stdio.h>
#include <stdlib.h>
void strcat(char s[],char t[]);
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
return 0;
}
void strcat(char s[],char t[]){
int i;
int j;
i=j=0;
while(s[i++]!='\0')
;
while((s[i++]=t[i++])!='\0')
;
}