c snprintf demo

1. snprintf(char *buff, size_t len, char *format, ....),格式化字符串到buff中

#include <pthread.h>
#include <stdio.h>
#include <unistd.h>


int data = 0;


int main() {
    char welcomeMsg[100];
    char *name = "guanxiansneg";
    snprintf(welcomeMsg, 100, "welcome %s to c", name);
    printf("welcomeMsg:%s
", welcomeMsg);

    return 0;
}
原文地址:https://www.cnblogs.com/luckygxf/p/12390283.html