---
# System prepended metadata

title: 電機一乙 11128271 蔡嘉泓 U-10 5/9 Hackmd作業

---

# 電機一乙 11128271 蔡嘉泓 U-10 5/9 Hackmd作業
## Pointer2
try to write a function to concatenate strings.
	void mystrcat ( char *dst, const char *src );
Test example:
char a[100] = "Hello";
char b[100] = "John";
mystrcat (a, ", ");
mystrcat (a, b);
printf("%s", a);


```c=
#include <stdio.h>

void mystrcat ( char *dst, const char *src );

int main()
{
    char a[100] = "Hello";
    char b[100] = "John";
    mystrcat (a, ", ");
    mystrcat (a, b);
    printf("%s", a);
	return 0;
}

void mystrcat ( char *dst, const char *src )
{
    while (*dst) dst++;
    for(; (*dst=*src)!=0; ) { dst++; src++; }
}
```
![](https://hackmd.io/_uploads/r1KswSaVn.png)
