Click here to Skip to main content
15,891,867 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Similar named function in 2 static .lib files problem Pin
Migounette8-Jan-10 12:40
Migounette8-Jan-10 12:40 
AnswerRe: Similar named function in 2 static .lib files problem Pin
Chesnokov Yuriy10-Jan-10 1:34
professionalChesnokov Yuriy10-Jan-10 1:34 
AnswerRe: Similar named function in 2 static .lib files problem Pin
Saurabh.Garg9-Jan-10 14:34
Saurabh.Garg9-Jan-10 14:34 
GeneralRe: Similar named function in 2 static .lib files problem Pin
Chesnokov Yuriy10-Jan-10 1:32
professionalChesnokov Yuriy10-Jan-10 1:32 
Questionconverting float from host to network order Pin
Vishal Kumar Soni8-Jan-10 5:01
Vishal Kumar Soni8-Jan-10 5:01 
AnswerRe: converting float from host to network order Pin
Moak8-Jan-10 8:36
Moak8-Jan-10 8:36 
GeneralRe: converting float from host to network order Pin
Vishal Kumar Soni8-Jan-10 23:57
Vishal Kumar Soni8-Jan-10 23:57 
AnswerRe: converting float from host to network order Pin
Graham Shanks8-Jan-10 11:26
Graham Shanks8-Jan-10 11:26 
The following will work:

float htonf(float value)
{
  float result;
  char* pSource = reinterpret_cast<char*>(&value);
  char* pDest = reinterpret_cast<char*>(&result);
  pDest[0] = pSource[3];
  pDest[1] = pSource[2];
  pDest[2] = pSource[1];
  pDest[3] = pSource[0];
  return result;
}


Warning: once a value has been converted to network order do not try to use it on the host, since it is almost certainly an invalid IEEE 754 format number.

Note that the above function also converts from network to host format.

Converting doubles is similar:

double htonf(double value)
{
  double result;
  char* pSource = reinterpret_cast<char*>(&value);
  char* pDest = reinterpret_cast<char*>(&result);
  pDest[0] = pSource[7];
  pDest[1] = pSource[6];
  pDest[2] = pSource[5];
  pDest[3] = pSource[4];
  pDest[4] = pSource[3];
  pDest[5] = pSource[2];
  pDest[6] = pSource[1];
  pDest[7] = pSource[0];
  return result;
}


Graham

Librarians rule, Ook!

QuestionRe: converting float from host to network order Pin
Moak8-Jan-10 12:21
Moak8-Jan-10 12:21 
AnswerRe: converting float from host to network order Pin
Graham Shanks8-Jan-10 12:58
Graham Shanks8-Jan-10 12:58 
GeneralRe: converting float from host to network order Pin
Moak8-Jan-10 13:14
Moak8-Jan-10 13:14 
GeneralRe: converting float from host to network order Pin
Vishal Kumar Soni8-Jan-10 23:58
Vishal Kumar Soni8-Jan-10 23:58 
Questionwhen will EndPage() failed in MFC Pin
kir_MFC8-Jan-10 4:07
kir_MFC8-Jan-10 4:07 
AnswerRe: when will EndPage() failed in MFC [modified] Pin
Nelek8-Jan-10 4:33
protectorNelek8-Jan-10 4:33 
AnswerRe: when will EndPage() failed in MFC Pin
PJ Arends8-Jan-10 7:29
professionalPJ Arends8-Jan-10 7:29 
QuestionHiding the column header in a CListCtrl Pin
maycockt8-Jan-10 1:24
maycockt8-Jan-10 1:24 
AnswerRe: Hiding the column header in a CListCtrl Pin
Abhi Lahare8-Jan-10 1:29
Abhi Lahare8-Jan-10 1:29 
AnswerRe: Hiding the column header in a CListCtrl Pin
maycockt8-Jan-10 1:32
maycockt8-Jan-10 1:32 
GeneralRe: Hiding the column header in a CListCtrl Pin
Abhi Lahare8-Jan-10 1:36
Abhi Lahare8-Jan-10 1:36 
GeneralRe: Hiding the column header in a CListCtrl Pin
maycockt8-Jan-10 1:42
maycockt8-Jan-10 1:42 
GeneralRe: Hiding the column header in a CListCtrl Pin
Chris Meech8-Jan-10 6:03
Chris Meech8-Jan-10 6:03 
QuestionHiding Mainframe,showing ChildFrame. Pin
Anu_Bala8-Jan-10 0:12
Anu_Bala8-Jan-10 0:12 
AnswerRe: Hiding Mainframe,showing ChildFrame. [modified] Pin
LunaticFringe8-Jan-10 3:07
LunaticFringe8-Jan-10 3:07 
AnswerRe: Hiding Mainframe,showing ChildFrame. Pin
Iain Clarke, Warrior Programmer8-Jan-10 10:57
Iain Clarke, Warrior Programmer8-Jan-10 10:57 
QuestionHi function with variable arguments Pin
hrishiS7-Jan-10 23:36
hrishiS7-Jan-10 23:36 

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.