I'm very new to C++ programming. I have a 3rd party app that can utilize Win32 DLLs. The test project I'm working on compiles without error, but in use doesn't seem to actually return the expected data.
With the below function Foo, the expectation is that the char array that is passed in will return the same values.
Instead, regardless of the data passed in my 3rd party app only sees the return value: 0
My suspicion is that I am not using the pointer 'char *data_out' correctly.
DemoLib.h:
#pragma once
#define DLL_EXP extern "C" __declspec(dllexport)
DLL_EXP void Foo(char* data_in, char *data_out);
DemoLib.cpp:
#include "stdafx.h"
#include "DemoLib.h"
#include <iostream>
DLL_EXP void Foo(char* data_in, char *data_out)
{
int a_size = sizeof(data_in) / sizeof(char);
std::string s_a = convertToString(data_in, a_size);
char strArray[100];
strcpy_s(strArray, s_a.c_str());
data_out = strArray;
}
std::string convertToString(char* a, int size)
{
int i;
std::string s = "";
for (i = 0; i < size; i++) {
s = s + a[i];
}
return s;
}
Exports.def:
LIBRARY DemoLib
EXPORTS
Foo @1