Add string to string in C with safe functions
问题 I want to copy the a file name to a string and append ".cpt" to it. But I am unable to do this with safe functions (strcat_s). Error: "String is not null terminated!". And I did set '\0', how to fix this using safe functions? size = strlen(locatie); size++; nieuw = (char*)malloc(size+4); strcpy_s(nieuw, size, locatie); nieuw[size] = '\0'; strcat_s(nieuw, 4, ".cpt"); // <-- crash puts(nieuw); 回答1: The size parameter of the _s functions is the size of the destination buffer, not the source. The