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

C / C++ / MFC

 
AnswerRe: Registry returning FILE_NOT_FOUND Pin
Randor 20-Jan-18 16:40
professional Randor 20-Jan-18 16:40 
GeneralRe: Registry returning FILE_NOT_FOUND Pin
Richard Andrew x6421-Jan-18 2:16
professionalRichard Andrew x6421-Jan-18 2:16 
GeneralRe: Registry returning FILE_NOT_FOUND Pin
Randor 21-Jan-18 6:26
professional Randor 21-Jan-18 6:26 
GeneralRe: Registry returning FILE_NOT_FOUND Pin
Richard Andrew x6421-Jan-18 9:32
professionalRichard Andrew x6421-Jan-18 9:32 
QuestionRe: Registry returning FILE_NOT_FOUND Pin
Richard MacCutchan20-Jan-18 21:11
mveRichard MacCutchan20-Jan-18 21:11 
AnswerRe: Registry returning FILE_NOT_FOUND Pin
Victor Nijegorodov21-Jan-18 1:07
Victor Nijegorodov21-Jan-18 1:07 
QuestionScript Writing in AutoHotKey Pin
ThatOldGuy19-Jan-18 3:11
ThatOldGuy19-Jan-18 3:11 
AnswerRe: Script Writing in AutoHotKey Pin
Richard MacCutchan19-Jan-18 4:00
mveRichard MacCutchan19-Jan-18 4:00 
GeneralRe: Script Writing in AutoHotKey Pin
ThatOldGuy19-Jan-18 4:12
ThatOldGuy19-Jan-18 4:12 
GeneralRe: Script Writing in AutoHotKey Pin
Rick York19-Jan-18 5:08
mveRick York19-Jan-18 5:08 
GeneralRe: Script Writing in AutoHotKey Pin
Richard MacCutchan19-Jan-18 5:29
mveRichard MacCutchan19-Jan-18 5:29 
GeneralRe: Script Writing in AutoHotKey Pin
ThatOldGuy19-Jan-18 7:12
ThatOldGuy19-Jan-18 7:12 
GeneralRe: Script Writing in AutoHotKey Pin
Richard MacCutchan19-Jan-18 8:06
mveRichard MacCutchan19-Jan-18 8:06 
GeneralRe: Script Writing in AutoHotKey Pin
ThatOldGuy19-Jan-18 8:49
ThatOldGuy19-Jan-18 8:49 
QuestionProblem with multiple bouncing balls program in C Pin
Member 1363226319-Jan-18 0:24
Member 1363226319-Jan-18 0:24 
AnswerRe: Problem with multiple bouncing balls program in C Pin
Richard MacCutchan19-Jan-18 0:36
mveRichard MacCutchan19-Jan-18 0:36 
AnswerRe: Problem with multiple bouncing balls program in C Pin
Member 1363226319-Jan-18 0:59
Member 1363226319-Jan-18 0:59 
GeneralRe: Problem with multiple bouncing balls program in C Pin
Richard MacCutchan19-Jan-18 1:05
mveRichard MacCutchan19-Jan-18 1:05 
GeneralRe: Problem with multiple bouncing balls program in C Pin
Member 1363226319-Jan-18 1:22
Member 1363226319-Jan-18 1:22 
GeneralRe: Problem with multiple bouncing balls program in C Pin
Richard MacCutchan19-Jan-18 1:23
mveRichard MacCutchan19-Jan-18 1:23 
GeneralRe: Problem with multiple bouncing balls program in C Pin
Member 1363226319-Jan-18 1:54
Member 1363226319-Jan-18 1:54 
GeneralRe: Problem with multiple bouncing balls program in C Pin
Richard MacCutchan19-Jan-18 2:51
mveRichard MacCutchan19-Jan-18 2:51 
AnswerRe: Problem with multiple bouncing balls program in C Pin
Jochen Arndt19-Jan-18 1:07
professionalJochen Arndt19-Jan-18 1:07 
You might get out of bound array accesses when step is always >= 0.63:
total=n*7;
num=(int *) malloc(total*sizeof(int));
// ...
do
{
    j=0;
    for(i=0; i<=n; i++)
    {
        if (step >= 0.03)
        {
            // Possible out of bound accesses here (j >= total)
            // ...
            j=j+7;
        }
    }
}
while (!kbhit());
You have to change the for loop to
for(i=0; i<n; i++)
I also don't understand why you are only updating when step is large enough. If that does not happen, balls at the end of the array will be updated less often than the initial ones.

You are checking if the new ball position is outside and inverts the direction if so but are still drawing the ball when outside. A better solution might be drawing it at the border (here for x):
if (num[j]+num[j+4]>=getmaxx() || num[j]-num[j+4]<=0)
{
    num[j+5] *= -1;
    if (num[j]+num[j+4] > getmaxx())
        num[j] = getmaxx() - num[j+4];
    if (num[j]-num[j+4] < 0)
        num[j] = num[j+4];
}

Finally it might not work as expected because you have up to 7 balls and did not handle overlapping ones. I guess you want to detect also ball collisions which would result in no overlapping. But that is also not handled by your code.
GeneralRe: Problem with multiple bouncing balls program in C Pin
Member 1363226319-Jan-18 1:53
Member 1363226319-Jan-18 1:53 
GeneralRe: Problem with multiple bouncing balls program in C Pin
Jochen Arndt19-Jan-18 2:21
professionalJochen Arndt19-Jan-18 2:21 

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.