"Julián Albo" <JULIANALBO@terra.es> skrev i meddelandet
news:3FC0942E.78027A66@terra.es...
Andrew escribió:
switch(m)
{
case 1:
{
ip_part=k[0];
m=0;
}
case 2:
{
ip_part=10*k[1]+k[0];
m=0;
}
case 3:
{
ip_part=100*k[2]+10*k[1]+k[2];
m=0;
}
default:
{
cout << "DEBUGGING m=.. " << m
<< " end of DEBUGGING " ;
return false;
}
}
You probably want a break at the end of each case.
else if((tempString[i]!=DOT) || (tempString[i]<'0') || >
(tempString[i]>'9'))
You probaly mean:
else if((tempString[i]!=DOT) && ( (tempString[i]<'0') || >
(tempString[i]>'9')) )
k[m]=(int)tempString[i];
This will return the ascii value of the digit. You should probarbly use:
k[m] = tempString[i] - '0';
case 2: ip_part=10*k[1]+k[0];
case 3: ip_part=100*k[2]+10*k[1]+k[2];
And add the digits in correct order, and in case 3 the correct digits:
case2: ip_part = 10*k[0]+k[1]
case 3: ip_part=100*k[0]+10*k[1]+k[2];
.