I have written a dll in cpp, successfully built but having some issues when trying set a value to string pointer.
My codes are as follow:
my sample usage of this dll in cpp
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include "OCRv1Dll.h"
using namespace std;
int main()
{
char *strIn = "abcd";
char *strOu = "";
int abc = autoOCR(strIn, strOu);
return 0;
}
My dll's body
// ocrv1dll.cpp : defines the exported functions for the dll application.
//
//#ifdef _MSC_VER
//#define _CRT_SECURE_NO_WARNINGS
//#endif
#include "stdafx.h"
__int32 __stdcall autoOCR(char* strIn, char* strOut)
{
__int32 intRtn = 6;
printf("Received string %s\n", strIn);
strOut += 17;
string temp = "abcd";
strcpy_s(strOut, 16, temp.c_str());
return intRtn;
}
Error has occured at
strcpy_s(strOut, 16, temp.c_str());
saying access violation memory location ...
Could you please enlighten me on this issue? thanks in advance!!