#include main () { const char *dc_name = NULL; char *dc_unc = NULL; TALLOC_CTX *mem_ctx = NULL; mem_ctx = talloc_new(NULL); dc_name = "mydc.foobar.local"; printf("Wrong: "); dc_unc = talloc_asprintf(mem_ctx, "%s%s", dc_name[0] == '\\'? "\\\\":"", talloc_strdup(mem_ctx, dc_name)); printf("dc_name: %s\t=> ", dc_name); printf("dc_unc: %s\n", dc_unc); printf("Right: "); dc_unc = talloc_asprintf(mem_ctx, "%s%s", dc_name[0] != '\\'? "\\\\":"", talloc_strdup(mem_ctx, dc_name)); printf("dc_name: %s\t=> ", dc_name); printf("dc_unc: %s\n", dc_unc); dc_name = "\\\\mydc.foobar.local"; printf("Wrong: "); dc_unc = talloc_asprintf(mem_ctx, "%s%s", dc_name[0] == '\\'? "\\\\":"", talloc_strdup(mem_ctx, dc_name)); printf("dc_name: %s\t=> ", dc_name); printf("dc_unc: %s\n", dc_unc); printf("Right: "); dc_unc = talloc_asprintf(mem_ctx, "%s%s", dc_name[0] != '\\'? "\\\\":"", talloc_strdup(mem_ctx, dc_name)); printf("dc_name: %s\t=> ", dc_name); printf("dc_unc: %s\n", dc_unc); talloc_free(mem_ctx); }