Dragonfly Q&A

Writing C++ strings to LogManager writeLog()

0 like 0 dislike

How is it possible to write a predefined string (say "message" of type "string") to the LogManager writeLog()? C++ won’t let me cast (void *) onto my message string; what is the correct way to pass a string/buffer to send() here?

asked Jun 23, 2014 in Tutorial by Questioner

1 Answer

0 like 0 dislike

To call writeLog() with a C++ "string", you need to extract the C "char *" string from it:

log_manager.writeLog("Sent to Client: '%s'", message.c_str());

As an FYI, the same syntax holds for using C++ strings with printf():

printf("Sent to Client:'%s'n", message.c_str());

 

answered Jun 23, 2014 by claypool
More information about Dragonfly can be found on the Dragonfly Home Page.
...