Click here to Skip to main content
15,909,445 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: ListBox focus Pin
RomTibi11-Feb-09 5:53
RomTibi11-Feb-09 5:53 
AnswerRe: ListBox focus Pin
Perspx9-Feb-09 7:38
Perspx9-Feb-09 7:38 
GeneralRe: ListBox focus Pin
RomTibi11-Feb-09 5:53
RomTibi11-Feb-09 5:53 
AnswerRe: ListBox focus Pin
David Crow9-Feb-09 10:30
David Crow9-Feb-09 10:30 
GeneralRe: ListBox focus Pin
RomTibi9-Feb-09 10:39
RomTibi9-Feb-09 10:39 
GeneralRe: ListBox focus Pin
David Crow9-Feb-09 10:40
David Crow9-Feb-09 10:40 
GeneralRe: ListBox focus Pin
RomTibi11-Feb-09 5:54
RomTibi11-Feb-09 5:54 
Questionreading floats in a struct Pin
Jon Hulatt9-Feb-09 6:50
Jon Hulatt9-Feb-09 6:50 
Hi all,

I have a struct a bit like this, which is the header to a file on disk:-

struct Header
{
    short a;
    short b;
    short c;
    float floatvalue;
}


I read the header from the disk like this:-

ReadFile(hFile,&header,sizeof(Header),&bytesRead,NULL);


Once I'd done that, the values in a,b,c are as expected, but the floatvalue is not.

However, if I adjust the struct so that instead of float, I have BYTE[4] as follows:-

struct Header
{
    short a;
    short b;
    short c;
    BYTE floatvalue[4];
}


And then after reading the header as before, I do:-

float f;
memcpy(&f,header.floatvalue,sizeof(float));


Then f contains the value expected.

I don't understand why the first version didn't work. Can anyone enlighten me please?

Thanks

Jon

using System.Beer;

AnswerRe: reading floats in a struct Pin
Code-o-mat9-Feb-09 7:18
Code-o-mat9-Feb-09 7:18 
GeneralRe: reading floats in a struct Pin
Jon Hulatt9-Feb-09 7:51
Jon Hulatt9-Feb-09 7:51 
GeneralRe: reading floats in a struct Pin
RomTibi9-Feb-09 10:38
RomTibi9-Feb-09 10:38 
QuestionGetAdaptersInfo returns all the Ethernet Cards MAC Pin
spicy_kid20009-Feb-09 4:04
spicy_kid20009-Feb-09 4:04 
AnswerRe: GetAdaptersInfo returns all the Ethernet Cards MAC Pin
Stuart Dootson9-Feb-09 4:25
professionalStuart Dootson9-Feb-09 4:25 
GeneralRe: GetAdaptersInfo returns all the Ethernet Cards MAC Pin
spicy_kid20009-Feb-09 4:51
spicy_kid20009-Feb-09 4:51 
GeneralRe: GetAdaptersInfo returns all the Ethernet Cards MAC Pin
Stuart Dootson9-Feb-09 7:27
professionalStuart Dootson9-Feb-09 7:27 
GeneralRe: GetAdaptersInfo returns all the Ethernet Cards MAC Pin
spicy_kid20009-Feb-09 19:02
spicy_kid20009-Feb-09 19:02 
GeneralRe: GetAdaptersInfo returns all the Ethernet Cards MAC Pin
Stuart Dootson9-Feb-09 21:18
professionalStuart Dootson9-Feb-09 21:18 
QuestionNeed information about Activex Control functions Pin
John5029-Feb-09 3:16
John5029-Feb-09 3:16 
AnswerRe: Need information about Activex Control functions Pin
led mike9-Feb-09 4:34
led mike9-Feb-09 4:34 
GeneralRe: Need information about Activex Control functions Pin
Stephen Hewitt9-Feb-09 5:13
Stephen Hewitt9-Feb-09 5:13 
GeneralRe: Need information about Activex Control functions Pin
led mike9-Feb-09 5:17
led mike9-Feb-09 5:17 
QuestionDisplaying exponential value in Edit box Pin
Member 46517419-Feb-09 3:13
Member 46517419-Feb-09 3:13 
AnswerRe: Displaying exponential value in Edit box [modified] Pin
Sarath C9-Feb-09 3:41
Sarath C9-Feb-09 3:41 
GeneralRe: Displaying exponential value in Edit box Pin
Stephen Hewitt9-Feb-09 5:15
Stephen Hewitt9-Feb-09 5:15 
GeneralRe: Displaying exponential value in Edit box Pin
Sarath C9-Feb-09 23:58
Sarath C9-Feb-09 23:58 

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.