Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Syntactical blunder.

Syntactical blunder.

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    esepich
    wrote on last edited by
    #1

    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; }

    T G 2 Replies Last reply
    0
    • E esepich

      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; }

      T Offline
      T Offline
      Ted Ferenc
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • E esepich

        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; }

        G Offline
        G Offline
        Gary R Wheeler
        wrote on last edited by
        #3

        Try this: nRet = sendto(s, **(char *)&**echoReq, sizeof(ECHOREQUEST), 0, lpstToAddr, sizeof(SOCKADDR_IN)) Your original line says you want to pass echoReq by value, whereas you really want to pass a pointer to it.


        Software Zen: delete this;

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups