reptile
November 30th, 2003, 05:18 PM
My question is about calling external "C" function with variable number of arguments.
I know how to call "C" function from msvcrt library.
For example if we want to call
int puts( char * s )
"C" function we must code something like that (from .NET documentation)
[DllImport("msvcrt", EntryPoint="puts")]
extern "C" int puts( [MarshalAs(UnmanagedType::LPStr)] String * );
Everything goes OK. But what I gotta do to call printf/sprintf like functions, functions with variable number of arguments.
When I code
[DllImport("msvcrt", EntryPoint="sprintf")]
extern "C" int sprintf( [MarshalAs(UnmanagedType::LPStr)] String *, [MarshalAs(UnmanagedType::LPStr)] String *, ... );
an exception occures!!!
Does anybody know? Help.
I know how to call "C" function from msvcrt library.
For example if we want to call
int puts( char * s )
"C" function we must code something like that (from .NET documentation)
[DllImport("msvcrt", EntryPoint="puts")]
extern "C" int puts( [MarshalAs(UnmanagedType::LPStr)] String * );
Everything goes OK. But what I gotta do to call printf/sprintf like functions, functions with variable number of arguments.
When I code
[DllImport("msvcrt", EntryPoint="sprintf")]
extern "C" int sprintf( [MarshalAs(UnmanagedType::LPStr)] String *, [MarshalAs(UnmanagedType::LPStr)] String *, ... );
an exception occures!!!
Does anybody know? Help.