_mbccpy

De RAD Studio
Aller à : navigation, rechercher

Remonter à String.h - Index


Header File

mbstring.h

Category

Memory and String Manipulation Routines

Prototype

void _mbccpy(unsigned char *dest, unsigned char *src);

Description

The _mbccpy function copies a multibyte character from src to dest. The _mbccpy function makes an implicit call to _ismbblead so that the src pointer references a lead byte. If src does not reference a lead byte, no copy is performed.

Return Value

None.

Example

#include <mbstring.h>
#include <iostream>

char* concat_strings(char* input, char* add) {
	/* Obtain the length of the add string */
	int add_len = strlen(add);
	char* result;

	/* Halt if there is nothing to do */
	if (!add || !add_len)
		return input;

	/* Extend input to hold the add */
	_mbsninc(input, add_len);

	result = input;
	/* Move to the end of the input so the copy can start */
	input += strlen(input);

	/* Copy one character at a time */
	while (*add) {
		_mbccpy(input, add);
		add++;
		input++;
	}

	/* Mark the end of the string */
	*input = '\0';
	return result;
}

int main() {
	char* d = new char;
	char* s = new char;
	char* r = new char;
	s = "Hello ";
	d = "world!";
	r = concat_strings(s, d);
	std::cout << r << std::endl;

	return 0;

}