# [SOLVED] How to solve an infinite loop?

• (2 Pages)
• 1
• 2

## 18 Replies - 1469 Views - Last Post: 16 May 2012 - 11:56 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=231683&amp;s=cf8040a70abbfe800660272a6852c297&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #16 KoenM

Reputation: -4
• Posts: 41
• Joined: 07-December 09

## Re: [SOLVED] How to solve an infinite loop?

Posted 12 May 2011 - 06:24 AM

jimblumberg, on 12 May 2011 - 07:03 AM, said:

With F defined as F[1001][4] then yes your code will be work. However you are learning/using bad habits. Arrays in C/C++ start at 0 and end at size - 1, trying for force starting at 1 is a bad practice. For one thing you are using more memory than you require. In this case if F is an integer you would be wasting 1000*3*sizeof(int) bytes, and if sizeof(int) is 4 that would be 12,000 bytes.

Jim

I fully understand that.
But to make the program more user-friendly I decided to keep it this way, at least for now.
Thanks anyway.

• Saucy!

Reputation: 5677
• Posts: 22,539
• Joined: 23-August 08

## Re: [SOLVED] How to solve an infinite loop?

Posted 12 May 2011 - 07:07 AM

How does an implementation detail such as array indexing at all affect the user? Jim is absolutely right, you are doing it wrong!

### #18 KoenM

Reputation: -4
• Posts: 41
• Joined: 07-December 09

## Re: [SOLVED] How to solve an infinite loop?

Posted 12 May 2011 - 07:20 AM

JackOfAllTrades, on 12 May 2011 - 08:07 AM, said:

How does an implementation detail such as array indexing at all affect the user? Jim is absolutely right, you are doing it wrong!

I know I am not yet a master-coder.
I am still a beginner at this.
Please, understand, I know what you mean, and I understand why I should change things.
But believe me, I have my reasons to keep it this way.
For those who are interested.
I have made a few changes in the program and it now works properly.
It gives the answer I seek in a fraction of a second.
Thanks you all, this topic is solved.
Can anyone tell me where I can show that this is solved?

### #19 BobRodes

Reputation: 551
• Posts: 2,911
• Joined: 19-May 09

## Re: [SOLVED] How to solve an infinite loop?

Posted 16 May 2012 - 11:56 AM

KoenM, on 12 May 2011 - 07:46 AM, said:

The horror...the horror...

KoenM, I'm quite sure that you have your reasons for keeping things this way. I'm also quite sure that they

The horror...the horror...

KoenM, I'm quite sure that you have your reasons for keeping things this way. I'm also quite sure that they are bad.

This post has been edited by BobRodes: 16 May 2012 - 12:00 PM