Dear all C++ and VB Expert,

i'm writing a DLL function using VC++ which returns a char*.

I declared local variable char * ReturnString. But when i use the sprintf function, it gives me an access violation.

//*********** DLL ***************
char * __stdcall GetString (){
char * ReturnString ;
sprintf(ReturnString,"%02x",144);

return ReturnString;
}

//*********** Test.exe ***********
void main(){

char * L_Add;

L_Add = GetString(); //<====== error after going in

printf("%s",L_Add);
}

'*******************************
I know it's the problem of the memory location but not sure how to fix it. Please direct me to a right position.

Also, this "GetString" function is intended to be use in a VB project. Thus another question has raised. Can i return a char * in my DLL so that VB can pick it up as string?

Any help will be greatly appreciated.


Graphite