how to send string from/To C++ (6.0) to C++ DLL?

Posted by Ahmed Mostafa on Stack Overflow See other posts from Stack Overflow or by Ahmed Mostafa
Published on 2012-04-03T10:40:39Z Indexed on 2012/04/03 11:30 UTC
Read the original article Hit count: 253

Filed under:
|
|

When I send text to my DLL and receive it as char*, something strange happens; if the text is less than 13 characters or greater than 77 characters the text returned is rubbish!

Here is my code:-

//(1) DLL function:

char* __stdcall ApplyArabicMapping( char* input)
{
    // 1-Conver char* to string
    std::string inputString = input;

    // 2-Calling our function
    string encodedStr = Encoding::arabicHandling(inputString);

    // 3-Convert from String to char*
    char* returnStr = (char*)encodedStr.c_str();
    return (returnStr);
}

//(2) Calling from C++ console application:

char* inputStr = "Some text";

char* resutls = ApplyArabicMapping(inputStr);

© Stack Overflow or respective owner

Related posts about c++

Related posts about string