Simple concatenate two strings

Simple concatenation of two strings to third one using standard libs. Just put two strings and as function result you got concatenated one.
char*
concat(char* first, char* second) {
	char* result = malloc(snprintf(NULL, 0, "%s%s", first, second)+1);
	sprintf(result, "%s%s", first, second);

	return result;
}

Responses

0 Replies