ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
There doesn't seem to be much documentation for this API but ...
try:
std::cout << row[0].get_string();
The error messsage are from ColData try to cast itself into a char* of some description but not quite finding the right operator.
Try explicitly casting it.
Hm.. The problem still remains. The goal is to return a pointer-to-string that contains the text that are in row[0].
I know there are *too* little documentation of this and the former MySQL++ has kinda wierd documentation to. And since the fork to mysqlcppapi I can't understand how this works since they have not documentated what is changed and so on.
So I could not find out what get_string() was for.
I can also make the function to return the message instead if taking it as an argument. The message is max 512 characters and it has to be returned to main.cc in some type that send() can use.
I have not understood yet what the double asterix ** is but now I got the error that it could not convert from char* to char** at the call to function() in main, first argument.
I tried to force a conversation by adding (char**) in front of the argument:
function((char**)&message[0], sizeof(message));
And then the program could be compiled. But now when I ran it it started to listen on a port and when a connection was made (this is when the program should send() the message to the client) then the server died with the informing error: "Killed".
sorry, should be
function(&message, ...)
not
function(&message[0], ...)
basically, since you are going to be filling a pointer when
doing strncpy(), you need to pass a pointer to that pointer,
hence &message. Otherwise, you pass a copy of the pointer,
which is not what you want.
Ok, I am getting what you mean with the pointer to a pointer. :P
But I still got an error. I tried two things this time to. First what you said &message which gave error:
Code:
src/connections.cc: In function `void* new_connection(void*)':
src/connections.cc:39: error: cannot convert `char (*)[512]' to `char**' for
argument `1' to `void mySQLwelcome(char**, int)'
And then I tried again to force conversation with (char**) but that ended in crashing the server when it tried to execute the code.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.