Syntactical blunder.
-
I know that it's there, I just can't figure out why this error is occuring. Compiling resources... Compiling... StdAfx.cpp Compiling... SSPing.cpp SSPingDlg.cpp C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\SSPROJECT\SSPing\SSPingDlg.cpp(204) : error C2664: 'sendto' : cannot convert parameter 2 from 'struct tagECHOREQUEST' to 'const char *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called Generating Code... Error executing cl.exe. SSPing.exe - 1 error(s), 0 warning(s) int CSSPingDlg::SendEchoRequest(SOCKET s, SOCKADDR_IN lpstToAddr) { static ECHOREQUEST echoReq; static nId = 1; static nSeq = 1; int nRet; echoReq.icmpHdr.icmp_type = ICMP_ECHOREQ; echoReq.icmpHdr.icmp_code = 0; echoReq.icmpHdr.icmp_cksum = 0; echoReq.icmpHdr.icmp_id = nId++; echoReq.icmpHdr.icmp_seq = nSeq++; for (nRet = 0; nRet < REQ_DATASIZE; nRet++) echoReq.cData[nRet] = ' '+nRet; echoReq.dwTime = GetTickCount(); echoReq.icmpHdr.icmp_cksum = checksum((u_short *)&echoReq, sizeof(ECHOREQUEST)); -----> nRet = sendto(s, echoReq, sizeof(ECHOREQUEST), 0, lpstToAddr, sizeof(SOCKADDR_IN)); return 0; }
-
I know that it's there, I just can't figure out why this error is occuring. Compiling resources... Compiling... StdAfx.cpp Compiling... SSPing.cpp SSPingDlg.cpp C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\SSPROJECT\SSPing\SSPingDlg.cpp(204) : error C2664: 'sendto' : cannot convert parameter 2 from 'struct tagECHOREQUEST' to 'const char *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called Generating Code... Error executing cl.exe. SSPing.exe - 1 error(s), 0 warning(s) int CSSPingDlg::SendEchoRequest(SOCKET s, SOCKADDR_IN lpstToAddr) { static ECHOREQUEST echoReq; static nId = 1; static nSeq = 1; int nRet; echoReq.icmpHdr.icmp_type = ICMP_ECHOREQ; echoReq.icmpHdr.icmp_code = 0; echoReq.icmpHdr.icmp_cksum = 0; echoReq.icmpHdr.icmp_id = nId++; echoReq.icmpHdr.icmp_seq = nSeq++; for (nRet = 0; nRet < REQ_DATASIZE; nRet++) echoReq.cData[nRet] = ' '+nRet; echoReq.dwTime = GetTickCount(); echoReq.icmpHdr.icmp_cksum = checksum((u_short *)&echoReq, sizeof(ECHOREQUEST)); -----> nRet = sendto(s, echoReq, sizeof(ECHOREQUEST), 0, lpstToAddr, sizeof(SOCKADDR_IN)); return 0; }
try:-
sendto(s, (char*) echoReq, sizeof(ECHOREQUEST), 0, lpstToAddr, sizeof(SOCKADDR_IN));
The spec says:-int sendto ( SOCKET s, const char *buf, int len, int flags, const struct sockaddr *to, int tolen );
Hell, there are no rules here-- we're trying to accomplish something. - Thomas A. Edison
-
I know that it's there, I just can't figure out why this error is occuring. Compiling resources... Compiling... StdAfx.cpp Compiling... SSPing.cpp SSPingDlg.cpp C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\SSPROJECT\SSPing\SSPingDlg.cpp(204) : error C2664: 'sendto' : cannot convert parameter 2 from 'struct tagECHOREQUEST' to 'const char *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called Generating Code... Error executing cl.exe. SSPing.exe - 1 error(s), 0 warning(s) int CSSPingDlg::SendEchoRequest(SOCKET s, SOCKADDR_IN lpstToAddr) { static ECHOREQUEST echoReq; static nId = 1; static nSeq = 1; int nRet; echoReq.icmpHdr.icmp_type = ICMP_ECHOREQ; echoReq.icmpHdr.icmp_code = 0; echoReq.icmpHdr.icmp_cksum = 0; echoReq.icmpHdr.icmp_id = nId++; echoReq.icmpHdr.icmp_seq = nSeq++; for (nRet = 0; nRet < REQ_DATASIZE; nRet++) echoReq.cData[nRet] = ' '+nRet; echoReq.dwTime = GetTickCount(); echoReq.icmpHdr.icmp_cksum = checksum((u_short *)&echoReq, sizeof(ECHOREQUEST)); -----> nRet = sendto(s, echoReq, sizeof(ECHOREQUEST), 0, lpstToAddr, sizeof(SOCKADDR_IN)); return 0; }
Try this:
nRet = sendto(s, **(char *)&**echoReq, sizeof(ECHOREQUEST), 0, lpstToAddr, sizeof(SOCKADDR_IN))
Your original line says you want to passechoReq
by value, whereas you really want to pass a pointer to it.
Software Zen:
delete this;