string hello;
        cin>>hello;
        sprintf(buf, "This server has been contacted time%s\n", hello);

I'm making a simple client-server program. I just want to know how do I get to print out the hello string inside the sprintf() >.< soz might be a very dumb question....

The error i keep getting is "can't pass objects of non-POD type"

You have to get there a const char * , which is what the c_str() function gives you (i.e. hello.c_str()).

How about doing something like

string msg = "This server has been contacted time";
msg += hello;
msg += "\n";

Then later, when you absolutely need a char array to call send(), do this send( fd, msg.c_str(), msg.length(), 0 );

ah awesome got it to work thx guys:D

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.