stefan,
*p = new char[STRING_SIZE];
doesnt compile - it complains about the new keyword
Main Topics
Browse All Topicshi,
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
thanks!
// Shared DATA declaration
#pragma data_seg(".SHARDATA")
#define STRING_SIZE 255
char acString[STRING_SIZE] = "\0";
#pragma data_seg()
__declspec( dllexport ) void getString(char** p)
{
*p = new char[STRING_SIZE];
strncpy ( acString, "test string", STRING_SIZE - 1);
strcpy(*p, acString);
}
__declspec( dllexport) void ReleaseString(char* p)
{
delete[] p;
}
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: stefan73Posted on 2004-10-07 at 02:18:39ID: 12246851
Hi sdlangers, ;
*p = new char[STRING_SIZE];
*p = (char*)malloc(STRING_SIZE)
delete[] p;
free(f);
The rest is C already.
Cheers!
Stefan