Sendto() function giving errors . How to debug them?
<pre><code>    /*
** talker.c -- a datagram "client" demo
*/

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;unistd.h&gt;
#include &lt;errno.h&gt;
#include &lt;string.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;sys/socket.h&gt;
#include &lt;netinet/in.h&gt;
#include &lt;arpa/inet.h&gt;
#include &lt;netdb.h&gt;
#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;


using namespace std ;
#define SERVERPORT "3200775" // the port users will be connecting to

int main()
{ string s;

ifstream f1 ("queries1.txt");
if (f1.is_open()) 

{
while (!f1.eof()) 
{
getline(f1,s);
cout&lt;&lt;s&lt;&lt;endl;
        }

}
    int sockfd;
    //char ch [] = "hello";

struct addrinfo hints, *servinfo, *p;
int rv;
int numbytes;

// if (argc != 3) {
// fprintf(stderr,"usage: talker hostname message\n");
// exit(1);
//}

memset(&amp;hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;

if ((rv = getaddrinfo("nunki.usc.edu", SERVERPORT, &amp;hints, &amp;servinfo)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
return 1;
}

// loop through all the results and make a socket
for(p = servinfo; p != NULL; p = p-&gt;ai_next) 
{
if ((sockfd = socket(p-&gt;ai_family, p-&gt;ai_socktype, p-&gt;ai_protocol)) == -1) 
{
perror("talker: socket");
continue;
}

break;
}

if (p == NULL) 
{
fprintf(stderr, "talker: failed to bind socket\n");
return 2;
}

//if ((numbytes = sendto(sockfd,ch, strlen(ch), 0,
// p-&gt;ai_addr, p-&gt;ai_addrlen)) == -1) {
//perror("talker: sendto");
//exit(1);

//for (f=0 ;f&lt;15; f++ )
 //   {

    char* mess = malloc(20*sizeof(char));
    sprintf(mess,s);
         if ((numbytes = sendto(sockfd,mess, s.length(), 0, p-&gt;ai_addr, p-&gt;ai_addrlen)) == -1) 
{ cout&lt;&lt;s; 
  perror("talker: sendto");
  exit(1);

} 
printf("talker: sent %d bytes to \n", numbytes);
cout&lt;&lt;endl;
//}

freeaddrinfo(servinfo);

//printf("talker: sent %d bytes to \n", numbytes);

close(sockfd);
return 0;
}
</code></pre>

<p>Sorry for the sloppy way of coding .  I am getting errors in this . How do i debug it ?</p>

<p>The errors are these</p>

<pre><code>test.cpp:84: error: invalid conversion from ‘void*’ to ‘char*’
test.cpp:85: error: cannot convert ‘std::string’ to ‘const char*’ for argument ‘2’ to ‘int sprintf(char*, const char*, ...)’
</code></pre>
