Alright, I have just now found I have a problem with char and int. If I wanted to enter an IP like 127.0.0.1 as Int it would read it as a charecter, if i had char it would read as an Integer. How do I use both at the same time
Printable View
Alright, I have just now found I have a problem with char and int. If I wanted to enter an IP like 127.0.0.1 as Int it would read it as a charecter, if i had char it would read as an Integer. How do I use both at the same time
huh?
You need to provide details. And I'd suggest asking this question in the networking forum.
I guess you could store the IP in a string...if that's what you're asking.
You could create a class that would allow you to quickly retrieve any aspect of it with a function call.
Although that may be overkill. I just love classes:D.Code:class IPaddr
{
public:
int num[4];
char *str();
char *str(int nIndex);
};
char * IPaddr::str()
{
char *temp=new char[32];
itoa(num[0],temp,10);
//etc
}
char *IPaddr::str(int nIndex)
{
char *temp=new char[4];
itoa(num[nIndex],temp,10);
return temp;
}