#include "stdio.h"
#include "string.h"

void Strncpy(char *to, const char *from, size_t count) {
    size_t n = (count + 7) / 8;
    switch (count % 8) {
        case 0:
            do {
                *to++ = *from++;
                case 7:
                    *to++ = *from++;
                case 6:
                    *to++ = *from++;
                case 5:
                    *to++ = *from++;
                case 4:
                    *to++ = *from++;
                case 3:
                    *to++ = *from++;
                case 2:
                    *to++ = *from++;
                case 1:
                    *to++ = *from++;
            } while (--n > 0);
    }
}

int main() {
    char buf[20] = {0};
    const char *str = "hello world";
    Strncpy(buf, str, strlen(str));
    printf("%s\n", buf);
    return 0;
}



int function(void) {
    static int i, state = 0;
    switch (state) {
        case 0:
            for (i = 0; i < 1; i++) {
                state = 1;
                return i;
        case 1:;
            }
    }
    return i;
}


备份地址: 【达夫设备,循环展开