Thread: true/false

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by DaveH View Post
    Thats what I thought, but wasn't sure. So i would be -1 and it would try to access the array. That would be attempting array access with an out of bounds index.
    I wasn't aware that 0 - 1 + 1 equaled negative one. It's the new math!

  2. #17
    Registered User
    Join Date
    Dec 2007
    Posts
    214
    Quote Originally Posted by tabstop View Post
    I wasn't aware that 0 - 1 + 1 equaled negative one. It's the new math!
    Okay, I see where I wasn't thinking correctly. i would be set to -1 inside the loop, but it would be incremented back to zero before the next loop iteration. But, this would become an infinite loop because : i=0, check arrary element at zero. That element is not valid. set i=-1. increment loop so i=0 again. repeat forever.

  3. #18
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by DaveH View Post
    Okay, I see where I wasn't thinking correctly. i would be set to -1 inside the loop, but it would be incremented back to zero before the next loop iteration. But, this would become an infinite loop because : i=0, check arrary element at zero. That element is not valid. set i=-1. increment loop so i=0 again. repeat forever.
    Except that the scanf was inside the loop, so we could get a new (hopefully valid) number.

  4. #19
    Registered User
    Join Date
    Dec 2007
    Posts
    214
    Quote Originally Posted by tabstop View Post
    Except that the scanf was inside the loop, so we could get a new (hopefully valid) number.
    You are right. Ignore me.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help.. true/false
    By salmansalman in forum C++ Programming
    Replies: 5
    Last Post: 11-24-2008, 10:10 AM
  2. FMOD implimentation, how'd you do it?
    By Jeremy G in forum Game Programming
    Replies: 10
    Last Post: 06-12-2004, 12:04 AM
  3. evaulate strcmp true/false
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 04-13-2002, 04:24 PM