User Tools

Site Tools


Concatenating two orxSTRINGs

#include "orx.h"
#ifdef __orxMSVC__ 
	#include "malloc.h"
const orxSTRING stringOne = "I like the beach. ";
const orxSTRING stringTwo = "And I like the waves.";
int length = orxString_GetLength(stringOne) + orxString_GetLength(stringTwo) + 1;
#ifdef __orxMSVC__ 
	orxCHAR *concatenatedString = (orxCHAR *)alloca(length * sizeof(orxCHAR));
#else /* __orxMSVC__ */ 
	orxCHAR concatenatedString[length] = {};
#endif /* __orxMSVC__ */
orxString_Print(concatenatedString, "%s%s", stringOne, stringTwo);
orxLOG("Your string is %s", concatenatedString);

Because the example is using a Variable Length Array in C, Visual Studio's compiler doesn't support this. Provision has to be made for that compiler. Read more about it here.

en/examples/objects/concatenating_two_strings.txt · Last modified: 2018/02/14 00:47 (4 years ago) (external edit)