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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CString to unsigned long

CString to unsigned long

Scheduled Pinned Locked Moved C / C++ / MFC
2 Posts 2 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.
  • I Offline
    I Offline
    Irish_GUI
    wrote on last edited by
    #1

    Hi, bascially i have an IP Address contained in a CString "10.10.10.1" i need a unsigned long representation of it. here is the function im using below but im not sure, if its right.. its hit and miss, works sometimes not others.. can anyone recommend an easier way of doing it or point out errors in the function int check1; CString m_ipSrc; unsigned long srcIp check1 = convertAddress(m_ipSrc, &srcIp) int DlgClass::convertAddress(const char *sIp, unsigned long *lIp) { int octets[4]; int i; const char * auxCad = sIp; *lIp = 0; for(i = 0; i < 4; i++) { octets[i] = atoi(auxCad); *lIp |= (octets[i] << (i*8)); auxCad = strchr(auxCad, '.'); auxCad++; } return 0; }

    RaviBeeR 1 Reply Last reply
    0
    • I Irish_GUI

      Hi, bascially i have an IP Address contained in a CString "10.10.10.1" i need a unsigned long representation of it. here is the function im using below but im not sure, if its right.. its hit and miss, works sometimes not others.. can anyone recommend an easier way of doing it or point out errors in the function int check1; CString m_ipSrc; unsigned long srcIp check1 = convertAddress(m_ipSrc, &srcIp) int DlgClass::convertAddress(const char *sIp, unsigned long *lIp) { int octets[4]; int i; const char * auxCad = sIp; *lIp = 0; for(i = 0; i < 4; i++) { octets[i] = atoi(auxCad); *lIp |= (octets[i] << (i*8)); auxCad = strchr(auxCad, '.'); auxCad++; } return 0; }

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      Perhaps this[^] article may help? /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      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