Hex IP to string
Hex IP to string
- Subject: Hex IP to string
- From: Manuel Darveau <email@hidden>
- Date: Tue, 19 Mar 2002 23:56:44 -0500
Hi!
I want to convert an IP in the form of "0xffffff00" to 255.255.255.0
I tried:
long val;
val = strtol([@"0xffffff00" cString], nil, 16);
NSLog(@"%@:%ld", subnet, val);
NSLog(@"Subnet:%ld.%ld.%ld.%ld", (val & 0xff000000) >> 24, (val &
0x00ff0000) >> 16, (val & 0x0000ff00) >> 8, (val & 0x000000ff));
This work fine with hex like 0x00ffffff but when you enter 0xff000000 it
seem to have an overflow.
Anybody see what I am missing?
Manuel Darveau
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.