AuthorMessage
Corayzon
Regular
Posts: 67

hey guys,
just recently i have started learning c++ (mfc app wiz apps) and am just screwing around with sockets to see what i can do...
My problems is i have a IDC_PORT editbox linked to m_strPort.
now when someone clicks the listen button, i cant convert the str in m_strPort to a long into which the m_Socket.SetLocalPort() needs.
any help would be very greate!
thankz in advance
Meka][Meka
Unstopable
Posts: 700

if u use the stl lib u can use something like
Code:

int main( )
{
     std::string tstr("321");
     int str;
     std::stringstream ss(tstr);
     ss >> str;
     std::cout << str;
     return 0;
}

or check this function out
Code:

bool string2int(char* digit, int& result) {
   result = 0;
   //--- Convert each digit char and add into result.
   while (*digit >= '0' && *digit <='9') {
      result = (result * 10) + (*digit - '0');
      digit++;
   }
   //--- Check that there were no non-digits at end.
   if (*digit != 0) {
      return false;
   }
   return true;
}

-/Meka][Meka
gemz
n00b
Posts: 32

dayum lol *feelz headache poppin up*....cnt believe i was gonna try n learn dis stuff
Corayzon
Regular
Posts: 67

cheers Meka][Meka,
ill use the bool string2int =]
im programming with a mfc app wiz, so im not sure if cout and cin stuff would work...
but ill try it all =]
thankz!