15,847,903 members
Home / Discussions / C / C++ / MFC

# C / C++ / MFC

 Re: Problem with multiple bouncing balls program in C Richard MacCutchan19-Jan-18 1:36 Richard MacCutchan 19-Jan-18 1:36
 Re: Problem with multiple bouncing balls program in C Member 1363226319-Jan-18 1:59 Member 13632263 19-Jan-18 1:59
 Re: Problem with multiple bouncing balls program in C Richard MacCutchan19-Jan-18 2:05 Richard MacCutchan 19-Jan-18 2:05
 Re: Problem with multiple bouncing balls program in C Member 1363226319-Jan-18 2:22 Member 13632263 19-Jan-18 2:22
 Re: Problem with multiple bouncing balls program in C Richard MacCutchan19-Jan-18 2:23 Richard MacCutchan 19-Jan-18 2:23
 Re: Problem with multiple bouncing balls program in C Member 1363226319-Jan-18 2:54 Member 13632263 19-Jan-18 2:54
 Re: Problem with multiple bouncing balls program in C Richard MacCutchan19-Jan-18 3:51 Richard MacCutchan 19-Jan-18 3:51
 Re: Problem with multiple bouncing balls program in C Jochen Arndt19-Jan-18 2:07 Jochen Arndt 19-Jan-18 2: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=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.
 Re: Problem with multiple bouncing balls program in C Member 1363226319-Jan-18 2:53 Member 13632263 19-Jan-18 2:53
 Re: Problem with multiple bouncing balls program in C Jochen Arndt19-Jan-18 3:21 Jochen Arndt 19-Jan-18 3:21
 Re: Problem with multiple bouncing balls program in C Member 1363226319-Jan-18 3:30 Member 13632263 19-Jan-18 3:30
 Re: Problem with multiple bouncing balls program in C Jochen Arndt19-Jan-18 3:56 Jochen Arndt 19-Jan-18 3:56
 Re: Problem with multiple bouncing balls program in C Victor Nijegorodov19-Jan-18 22:21 Victor Nijegorodov 19-Jan-18 22:21
 Re: Problem with multiple bouncing balls program in C Rick York24-Jan-18 8:17 Rick York 24-Jan-18 8:17
 convert feet and inches to centimeters nithiin_sai18-Jan-18 15:42 nithiin_sai 18-Jan-18 15:42
 Re: convert feet and inches to centimeters Jim Meadors18-Jan-18 16:49 Jim Meadors 18-Jan-18 16:49
 Re: convert feet and inches to centimeters Victor Nijegorodov18-Jan-18 21:38 Victor Nijegorodov 18-Jan-18 21:38
 Re: convert feet and inches to centimeters CPallini18-Jan-18 22:47 CPallini 18-Jan-18 22:47
 Re: convert feet and inches to centimeters David Crow19-Jan-18 4:16 David Crow 19-Jan-18 4:16
 Start app without taskbar icon _Flaviu17-Jan-18 2:56 _Flaviu 17-Jan-18 2:56
 Re: Start app without taskbar icon Richard MacCutchan17-Jan-18 3:11 Richard MacCutchan 17-Jan-18 3:11
 Re: Start app without taskbar icon Jochen Arndt17-Jan-18 3:20 Jochen Arndt 17-Jan-18 3:20
 Re: Start app without taskbar icon _Flaviu18-Jan-18 2:09 _Flaviu 18-Jan-18 2:09
 Re: Start app without taskbar icon leon de boer18-Jan-18 2:40 leon de boer 18-Jan-18 2:40
 Re: Start app without taskbar icon Jochen Arndt18-Jan-18 3:07 Jochen Arndt 18-Jan-18 3:07
 Last Visit: 31-Dec-99 19:00     Last Update: 28-Feb-24 0:11 Refresh ᐊ Prev1...300301302303304305306307308309 Next ᐅ