_mbsninc

From RAD Studio
Jump to: navigation, search

Go Up to string.h Index


Header File

mbstring.h

Category

Memory and String Manipulation Routines

Prototype

unsigned char *_mbsninc(const unsigned char *str, size_t num);

Description

The functions increment the character array str by num number of characters.

These functions should be accessed through the portable macro, _tcsninc, defined in tchar.h.

Return value

The functions return a pointer to the resized character string specified by the argument str.

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;

}