convert simple c++ code to equivilant c code?
Posted on 2004-10-07
i am a .net developer and know a small bit about c/c++
i dont know if this is possible, but i have a program written in c as a DLL that NEARLY does what i need. im basically trying to get it to pass one of its strings back to .net code by supplying .net with a function that it can call to get the string in question
i have made up a test C++ DLL with the same type of code that i need and it passes the string back perfectly to .net. but when i try to use this code in the c DLL, it fails. i think it is because i dont have the stdafx.h included - and i cant for the life of me get it to compile when i do include it. is there another way around this? or does anyone know how to get these two functions to work in C without including that file?
the only restriction is that they must be exactly like below in terms of the function argument - i.e. i need to pass in a char** and i'm nearly sure i need to release it as per the other function to avoid memory leaks. i also need the shared data segment - since this is what is used in the other c DLL
// Shared DATA declaration
#define STRING_SIZE 255
char acString[STRING_SIZE] = "\0";
__declspec( dllexport ) void getString(char** p)
*p = new char[STRING_SIZE];
strncpy ( acString, "test string", STRING_SIZE - 1);
__declspec( dllexport) void ReleaseString(char* p)