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

C / C++ / MFC

 
QuestionRe: Smaller than a byte Pin
Mark Salsbery27-Sep-07 10:13
Mark Salsbery27-Sep-07 10:13 
AnswerRe: Smaller than a byte Pin
Waldermort27-Sep-07 10:15
Waldermort27-Sep-07 10:15 
GeneralRe: Smaller than a byte Pin
Mark Salsbery27-Sep-07 10:29
Mark Salsbery27-Sep-07 10:29 
GeneralRe: Smaller than a byte Pin
thestrat27-Sep-07 21:16
thestrat27-Sep-07 21:16 
AnswerRe: Smaller than a byte Pin
led mike27-Sep-07 10:06
led mike27-Sep-07 10:06 
AnswerRe: Smaller than a byte Pin
Chris Losinger27-Sep-07 10:48
professionalChris Losinger27-Sep-07 10:48 
GeneralRe: Smaller than a byte Pin
Waldermort27-Sep-07 10:59
Waldermort27-Sep-07 10:59 
AnswerRe: Smaller than a byte Pin
Sameerkumar Namdeo27-Sep-07 17:42
Sameerkumar Namdeo27-Sep-07 17:42 
Original struct
<br />
struct aablock<br />
{<br />
   BYTE Flag : 1; <br />
   BYTE State : 3;<br />
};<br />


Original array of size 512
<br />
MAXSIZE = 512<br />
aablock aa[MAXSIZE];<br />



Modified Struct
<br />
struct bbblock<br />
{<br />
   BYTE FlagOdd : 1; <br />
   BYTE StateOdd : 3;<br />
   BYTE FlagEven : 1; <br />
   BYTE StateEven : 3;<br />
};<br />
<br />
try to suffle the elements if size of this struct > sizeof(BYTE)<br />


if you are having an array of size say 512 then you may declare array with half of that size.
Each element will store 2 elements of original struct

<br />
bbblock bb[MAXSIZE/2];<br />
<br />
j = -1;<br />
for(i = 0; i < MAXSIZE/2; ++i)<br />
{<br />
j++ // j = 0, 2, 4, 6...<br />
bb[i].FlagEven = aa[j].Flag;<br />
bb[i].StateEven = aa[j].State;<br />
j++; // j = 1, 3, 5.....<br />
bb[i].FlagOdd = aa[j].Flag;<br />
bb[i].StateOdd = aa[j].State;<br />
}<br />

QuestionRe: Smaller than a byte Pin
zakkas248327-Sep-07 23:49
zakkas248327-Sep-07 23:49 
AnswerRe: Smaller than a byte Pin
Iain Clarke, Warrior Programmer28-Sep-07 5:31
Iain Clarke, Warrior Programmer28-Sep-07 5:31 
QuestionNeed a best possible alternative?? Pin
Kiran Satish27-Sep-07 7:08
Kiran Satish27-Sep-07 7:08 
AnswerRe: Need a best possible alternative?? Pin
Mark Salsbery27-Sep-07 7:31
Mark Salsbery27-Sep-07 7:31 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish1-Oct-07 10:41
Kiran Satish1-Oct-07 10:41 
QuestionRe: Need a best possible alternative?? Pin
Mark Salsbery1-Oct-07 11:15
Mark Salsbery1-Oct-07 11:15 
AnswerRe: Need a best possible alternative?? Pin
Kiran Satish1-Oct-07 11:34
Kiran Satish1-Oct-07 11:34 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery1-Oct-07 11:53
Mark Salsbery1-Oct-07 11:53 
GeneralRe: Need a best possible alternative?? [modified] Pin
Kiran Satish2-Oct-07 5:40
Kiran Satish2-Oct-07 5:40 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery2-Oct-07 5:48
Mark Salsbery2-Oct-07 5:48 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery2-Oct-07 6:34
Mark Salsbery2-Oct-07 6:34 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery2-Oct-07 7:01
Mark Salsbery2-Oct-07 7:01 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish2-Oct-07 7:42
Kiran Satish2-Oct-07 7:42 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery2-Oct-07 8:13
Mark Salsbery2-Oct-07 8:13 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish2-Oct-07 8:21
Kiran Satish2-Oct-07 8:21 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery2-Oct-07 8:25
Mark Salsbery2-Oct-07 8:25 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish2-Oct-07 8:41
Kiran Satish2-Oct-07 8:41 

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.