c strncpy strncat函数 demo

时间:2021-10-29 17:44:20

#include <stdio.h>
#include <string.h>


int main(int argc, char **argv) {
    char city[50] = "chengdu";
    char name[30] = "guanxianseng";
    char cityAndName[90];
    strncpy(cityAndName, city, 50);
    strncat(cityAndName, "_", 1);
    strncat(cityAndName, name,30);
    printf("cityAndName:%sn", cityAndName);

    return 0;
}

  c strncpy strncat函数 demo