---
# System prepended metadata

title: 05/08

---

# 05/08
## Practice
```c =
#include<stdio.h>
#include<string.h>
    int main()
    {
        char a[100]="Hello";
        char b[100]="John";
        char dst1[100];
        char dst2[100];
        strcpy1(dst1,s);
        strcpy1(dst2,s);
        printf("str=%s\n",dst1);
        printf("str=%s\n",dst2);
        return 0;
    }
    void strcpy1(char *dst1, char *src1)
    {
        for((*dst1=*src1)!=0;dst1++,src1++);
    }
    void strcpy2(char *dst2, char *src2)
    {
        for((*dst2=*src2)!=0;dst2++,src2++);
    }
    
# HW
'''c =
    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++;
        }
        while (*src) 
        {
            *dst++ = *src++;
        }
        *dst = '\0';
    }
```
# 作業2
```c=
#include <stdio.h>
#include <stdlib.h>

int main() {

    int choice;
    do {
        printf("Choose a function, enter 0 to finish:\n");
        printf("1 Show list of positions to be hired\n");
        printf("2 Show list of already hired positions\n");
        printf("3 Show list of already hired positions\n");
        printf("4 Hire a person\n");
        printf("5 Fire a person\n");
        scanf("%d", &choice);
        switch (choice) {
            case 1:
                printf("Show numbers in a row\n");
                break;
            case 2:
                printf("Sort by number\n");
                break;
            case 3:
                printf("Sort by name\n");
                break;
            case 4:
                printf("Input number and name to set a position\n");
                break;
            case 5:
                printf("Input number to fire a person\n");
                break;
            default:
                printf("Invalid choice. Try again.\n");
                break;
        }
    } while (choice != 0);
    return 0;
}
