Click here to Skip to main content
15,917,645 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to update the screen continuously when I keep the key pressing Pin
followait19-Nov-07 3:40
followait19-Nov-07 3:40 
GeneralRe: How to update the screen continuously when I keep the key pressing Pin
Nelek19-Nov-07 21:44
protectorNelek19-Nov-07 21:44 
GeneralRe: How to update the screen continuously when I keep the key pressing Pin
followait20-Nov-07 1:40
followait20-Nov-07 1:40 
QuestionDifferent displays on two computers with same screen resolution. [modified] Pin
followait16-Nov-07 16:57
followait16-Nov-07 16:57 
AnswerRe: Different displays on two computers with same screen resolution. Pin
Nelek18-Nov-07 22:07
protectorNelek18-Nov-07 22:07 
Questiona pointer i can not delete! Pin
King Tran16-Nov-07 16:17
King Tran16-Nov-07 16:17 
AnswerRe: a pointer i can not delete! Pin
followait16-Nov-07 17:09
followait16-Nov-07 17:09 
AnswerRe: a pointer i can not delete! Pin
Jheriko++17-Nov-07 16:00
Jheriko++17-Nov-07 16:00 
Your illegal access is where j is reaching 90 when i is 30, the array bounds are 120*30, not 120*30 + 90 for pDib1, so "+ j" is taking you outside of the array.

Is this code doing what you want? The k variable here is redundant.

...
int k=0; // k = 0
for(int j=0;j<90; ) // k not modified
{
pDib1[i*120+j+k]=pDib2[i*92+j++]; // k not modified
pDib1[i*120+j+k]=pDib2[i*92+j++]; // etc...
pDib1[i*120+j+k]=pDib2[i*92+j++];
pDib1[i*120+j+k]=0;
}

Also, a much better way to access an array like this is to increment to vars by 120 and 92 for each loop with i, saves the continual multiplication by constants, a slow down which dwarfs any speed benefit you gain from putting your increment inside the index. Consider:

int a=0, b=0;
for(int i=0;i<30;++i)
{
for(int j=0;j<90;j+=3)
{
pDib1[a+j]=pDib2[b+j];
pDib1[a+j]=pDib2[b+j+1];
pDib1[a+j]=pDib2[b+j+2];
pDib1[a+j]=0;
}
a+=120;
b+=92;
}

This is faster and more legible (and still broken!).

Hope this helps.
GeneralRe: a pointer i can not delete! Pin
King Tran19-Nov-07 1:33
King Tran19-Nov-07 1:33 
Questionhow to get all the xml content using MSXML? Pin
lostangels16-Nov-07 15:54
lostangels16-Nov-07 15:54 
QuestionRe: how to get all the xml content using MSXML? Pin
bob1697217-Nov-07 6:01
bob1697217-Nov-07 6:01 
QuestionInsert popup menu Pin
Tony Teveris16-Nov-07 14:57
Tony Teveris16-Nov-07 14:57 
AnswerRe: Insert popup menu Pin
Hamid_RT16-Nov-07 21:21
Hamid_RT16-Nov-07 21:21 
GeneralRe: Insert popup menu Pin
Tony Teveris18-Nov-07 10:46
Tony Teveris18-Nov-07 10:46 
GeneralRe: Insert popup menu Pin
Hamid_RT18-Nov-07 20:42
Hamid_RT18-Nov-07 20:42 
Questionintialization failure? Pin
acerunner31616-Nov-07 12:03
acerunner31616-Nov-07 12:03 
AnswerRe: intialization failure? Pin
ThatsAlok17-Nov-07 0:16
ThatsAlok17-Nov-07 0:16 
GeneralRe: intialization failure? Pin
acerunner31619-Nov-07 11:57
acerunner31619-Nov-07 11:57 
Question[Message Deleted] Pin
azigrec16-Nov-07 9:18
azigrec16-Nov-07 9:18 
QuestionRe: problem Pin
Maximilien16-Nov-07 9:46
Maximilien16-Nov-07 9:46 
QuestionRe: problem Pin
David Crow16-Nov-07 10:56
David Crow16-Nov-07 10:56 
GeneralRe: problem Pin
Peter Weyzen16-Nov-07 11:17
Peter Weyzen16-Nov-07 11:17 
GeneralRe: problem Pin
David Crow17-Nov-07 3:30
David Crow17-Nov-07 3:30 
AnswerRe: problem Pin
Mark Salsbery16-Nov-07 11:29
Mark Salsbery16-Nov-07 11:29 
AnswerRe: problem Pin
Mark Salsbery16-Nov-07 11:43
Mark Salsbery16-Nov-07 11:43 

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.