Aida
2012-01-28 10:33:14 UTC
char *concat(char *a, char *b){
int length;
for (length = 0; *a !='\0'; *a++){
length++;
}
int len;
for (len = 0; *b != '\0'; *b++){
len++;
}
char *cc = malloc((length+len+1)*sizeof(char));
char *c = *cc;
int i;
for (i = 0; i< length; i++){
*(c+i) = *(a+i);
}
for (i = 0; i< len; i++){
*(c+i) = *(b+i);
}
*c = '\0';
*c = *cc;
printf("%s\n", *c);