Date:2012-08-11
头文件strcat.h:
#ifndef STRCAT_H #define STRCAT_H 1 void strcat(char *a,const char *b) { while ( *a!='\0' ) { a++; } while ( *b!='\0' ) { *a++=*b++; } }
测试这个函数:
#include <stdio.h> #include <stdlib.h> #include "strcat.h" #include "strcpy.h" int main(int argc, const char *argv[]) { char *p=(char *)malloc(12*sizeof(char)); strcpy(p,"hello"); strcat(p," world"); printf("%s\n",p); return 0; }