Hello, I have this C++ code, I dunno how it works..

Anyway, I'd like to have it translated to Delphi.

If anyone can help me out, I'd be glad.

typedef void (*t_ChatPrint)		( char * );
t_ChatPrint	ChatPrint		= (t_ChatPrint)0x0054E410;
void ChatPrintf( const char *format, ... )
{
	va_list	ap;
	char	szBuffer[512] = "";

	va_start( ap, format );
	_vsnprintf_s( szBuffer, 512, 511, format, ap );
	va_end( ap );

	ChatPrint( szBuffer );
}

We use it like this:

ChatPrintf("Hello my %s.","friend");

Thanks in advance.

Recommended Answers

All 5 Replies

Why would you want to translate something that's hard wired to a specific address?

typedef void (*t_ChatPrint) ( char * );
t_ChatPrint ChatPrint = (t_ChatPrint)0x0054E410;

Your function pointer ChatPrint is hard wired to 0x0054E410..

Can I ask you a question? Why are you translating code when you don't even know its function.

I do know what it does, just dont know how it works.

This functions prints a message inside the chat of a game.

Well quickly, the function 'ChatPrintf' is collecting its arguments in a 'buffer' szBuffer according to the format string 'const char *format' and then handing the buffer off to your function pointer 'ChatPrint'.

If you hope to understand this please read this link..

http://www.cprogramming.com/tutorial/lesson17.html

I understand it, but I want to translate this code to Delphi. I know more delphi than C++, I could do more things with this code in delphi.

*bump*.

I dont know how to translate it to delphi. Any1 can help me?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.