I Have the following situation that I don't understand. I have an app where from NodeJS I'm calling a C++ function using Nan. The code on the C++ side is as follows:
using namespace std;
using namespace Nan;
using namespace v8;
// The function that we are going to call from NodeJS
strcpy (str,"these ");
strcat (str,"strings ");
strcat (str,"are ");
// Send the buffer back to NodeJS with the result of our calculation.
NewBuffer((char *) str, 80)
// The constructor
// Expose the method or methods to NodeJS
// Load the constructor
I think the problem is that
char str; will be allocated in the stack and once your
Combine method is finished it will be deallocated(popped from the stack) and overwritten with other stuff that gets pushed into the stack.
Declare it as
char* str; and allocate it dynamically with
str = new char;. Then do all those initializations with strcpy and strcat.