[SOLVED] How to solve an infinite loop?

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 1469 Views - Last Post: 16 May 2012 - 11:56 AM Rate Topic: -----

#16 KoenM  Icon User is offline

  • New D.I.C Head

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

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

Posted 12 May 2011 - 06:24 AM

View Postjimblumberg, 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.
Was This Post Helpful? 0
  • +
  • -

#17 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5677
  • View blog
  • 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!
Was This Post Helpful? 0
  • +
  • -

#18 KoenM  Icon User is offline

  • New D.I.C Head

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

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

Posted 12 May 2011 - 07:20 AM

View PostJackOfAllTrades, 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!


Look, I thank you for all your advice.
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?
Was This Post Helpful? 0
  • +
  • -

#19 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 551
  • View blog
  • 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

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2