Click here to Skip to main content
15,908,444 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ADO in C++ Pin
Christian Graus21-Jun-05 16:38
protectorChristian Graus21-Jun-05 16:38 
GeneralRe: ADO in C++ Pin
John M. Drescher21-Jun-05 17:49
John M. Drescher21-Jun-05 17:49 
GeneralRe: ADO in C++ Pin
BlackDice22-Jun-05 2:28
BlackDice22-Jun-05 2:28 
GeneralExtending VS.Net 2003 Pin
Phil Martin21-Jun-05 14:42
professionalPhil Martin21-Jun-05 14:42 
GeneralNetwork programming questions Pin
Tom Archer21-Jun-05 14:20
Tom Archer21-Jun-05 14:20 
GeneralRe: Network programming questions Pin
Ravi Bhavnani21-Jun-05 15:08
professionalRavi Bhavnani21-Jun-05 15:08 
GeneralRe: Network programming questions Pin
Tom Archer21-Jun-05 16:07
Tom Archer21-Jun-05 16:07 
GeneralRe: Network programming questions Pin
Christian Graus21-Jun-05 16:38
protectorChristian Graus21-Jun-05 16:38 
It's an order of operations problem - put brackets around everything after the cast to unsigned char, the number is getting cast first, then divided.

I'd also replace the 256 divides with shifts.

void convertLongToIpAddress (long nLong,
unsigned char& ch0,
unsigned char& ch1,
unsigned char& ch2,
unsigned char& ch3) // lowest part
{
ch0 = (unsigned char) ((nLong & 0xFF000000) >> 24);
ch1 = (unsigned char) ((nLong & 0x00FF0000) >> 16);
ch2 = (unsigned char) ((nLong & 0x0000FF00) >> 8);
ch3 = (unsigned char) (nLong % 256);
}

Christian Graus - Microsoft MVP - C++
GeneralRe: Network programming questions Pin
Ravi Bhavnani21-Jun-05 18:57
professionalRavi Bhavnani21-Jun-05 18:57 
GeneralRe: Network programming questions Pin
Bob Stanneveld21-Jun-05 21:09
Bob Stanneveld21-Jun-05 21:09 
GeneralRe: Network programming questions Pin
Christian Graus22-Jun-05 2:37
protectorChristian Graus22-Jun-05 2:37 
GeneralRe: Network programming questions Pin
Bob Stanneveld22-Jun-05 2:48
Bob Stanneveld22-Jun-05 2:48 
GeneralRe: Network programming questions Pin
Christian Graus22-Jun-05 14:50
protectorChristian Graus22-Jun-05 14:50 
GeneralRe: Network programming questions Pin
Bob Stanneveld22-Jun-05 20:32
Bob Stanneveld22-Jun-05 20:32 
GeneralRe: Network programming questions Pin
Christian Graus23-Jun-05 13:07
protectorChristian Graus23-Jun-05 13:07 
GeneralRe: Network programming questions Pin
Bob Stanneveld23-Jun-05 21:08
Bob Stanneveld23-Jun-05 21:08 
GeneralRe: Network programming questions Pin
Rick York22-Jun-05 6:22
mveRick York22-Jun-05 6:22 
GeneralRe: Network programming questions Pin
Christian Graus22-Jun-05 14:50
protectorChristian Graus22-Jun-05 14:50 
GeneralRe: Network programming questions Pin
David Crow22-Jun-05 3:52
David Crow22-Jun-05 3:52 
GeneralRe: Network programming questions Pin
Rick York22-Jun-05 6:23
mveRick York22-Jun-05 6:23 
GeneralEnumProcesses Problem!!! Pin
lewislewis_lewis21-Jun-05 11:27
lewislewis_lewis21-Jun-05 11:27 
GeneralRe: EnumProcesses Problem!!! Pin
Blake Miller21-Jun-05 11:33
Blake Miller21-Jun-05 11:33 
GeneralVector Pin
GreenLantern21-Jun-05 11:24
GreenLantern21-Jun-05 11:24 
GeneralRe: Vector Pin
Budric B.21-Jun-05 11:31
Budric B.21-Jun-05 11:31 
GeneralRe: Vector Pin
Giles21-Jun-05 11:46
Giles21-Jun-05 11:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.