Click here to Skip to main content
16,011,542 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Edit box and cursor position Pin
Jack Puppy19-Nov-04 0:49
Jack Puppy19-Nov-04 0:49 
GeneralRe: Edit box and cursor position Pin
22491719-Nov-04 0:57
22491719-Nov-04 0:57 
GeneralSaving variables with odd bit sizes Pin
rikkemus19-Nov-04 0:25
rikkemus19-Nov-04 0:25 
GeneralRe: Saving variables with odd bit sizes Pin
Jack Puppy19-Nov-04 0:32
Jack Puppy19-Nov-04 0:32 
GeneralRe: Saving variables with odd bit sizes Pin
Steve S19-Nov-04 0:43
Steve S19-Nov-04 0:43 
GeneralRe: Saving variables with odd bit sizes Pin
rikkemus19-Nov-04 1:16
rikkemus19-Nov-04 1:16 
GeneralRe: Saving variables with odd bit sizes Pin
Bob Flynn19-Nov-04 1:14
Bob Flynn19-Nov-04 1:14 
GeneralRe: Saving variables with odd bit sizes Pin
Henry miller19-Nov-04 2:14
Henry miller19-Nov-04 2:14 
I'm not sure if this will help, but look at your bits closely to see if a bit field can be used. This works best if your always access data in a definate pattern that fits into a struct well.

For instance if you had 4 bits you could do

struct myStruct {
BYTE a :4;
BYTE b :4;
}

Since you are dealing with 11 bits, something that simple won't work, but this might. Note that I managed to fit 4 different things into 6 bytes

struct myStruct2 {
short a :11;
short b1 :5;
short b2 :6;
short c1 :10;
short c2 :1;
short d :11;
...
}

Now you just need a class to access these, because b and c are divided up into two different shorts!

You also need to look into pragmas so that your strucutre is packed, otherwise you gain nothing.

#pragma pack(1)
// data
#pragma pack()

Last warning: your save file will not be portable to other systems! If your professor cares about this (and he should, but likely won't) you will have to use a different suggestion.

In the real world I would guess that this does not work very well. In the real world though we would use zlib, while in school there is good reason they don't let you use that. I'm offering this mostly as a learning exercise for you.
GeneralRe: Saving variables with odd bit sizes Pin
Bob Flynn19-Nov-04 2:34
Bob Flynn19-Nov-04 2:34 
GeneralRe: Saving variables with odd bit sizes Pin
rikkemus19-Nov-04 2:55
rikkemus19-Nov-04 2:55 
GeneralRe: Saving variables with odd bit sizes Pin
Bob Flynn19-Nov-04 3:53
Bob Flynn19-Nov-04 3:53 
GeneralRe: Saving variables with odd bit sizes Pin
Henry miller19-Nov-04 6:03
Henry miller19-Nov-04 6:03 
GeneralRe: Saving variables with odd bit sizes Pin
rikkemus19-Nov-04 12:21
rikkemus19-Nov-04 12:21 
Generalnewbie needs help Pin
marinme19-Nov-04 0:19
marinme19-Nov-04 0:19 
GeneralRe: newbie needs help Pin
Steve S19-Nov-04 0:27
Steve S19-Nov-04 0:27 
GeneralRe: newbie needs help Pin
toxcct19-Nov-04 1:01
toxcct19-Nov-04 1:01 
GeneralRe: newbie needs help Pin
Henry miller19-Nov-04 2:19
Henry miller19-Nov-04 2:19 
GeneralRe: newbie needs help Pin
toxcct19-Nov-04 5:40
toxcct19-Nov-04 5:40 
GeneralRe: newbie needs help Pin
Jeryth2-Feb-05 6:14
Jeryth2-Feb-05 6:14 
GeneralRe: newbie needs help Pin
toxcct3-Feb-05 2:47
toxcct3-Feb-05 2:47 
GeneralDatabase for C++ Pin
Gammenon18-Nov-04 23:14
Gammenon18-Nov-04 23:14 
GeneralRe: Database for C++ Pin
Steve S18-Nov-04 23:44
Steve S18-Nov-04 23:44 
GeneralRe: Database for C++ Pin
Gammenon18-Nov-04 23:53
Gammenon18-Nov-04 23:53 
GeneralRe: Database for C++ Pin
Steve S19-Nov-04 0:01
Steve S19-Nov-04 0:01 
GeneralRe: Database for C++ Pin
Gammenon19-Nov-04 0:25
Gammenon19-Nov-04 0:25 

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.