true/false

This is a discussion on true/false within the C Programming forums, part of the General Programming Boards category; Originally Posted by DaveH Thats what I thought, but wasn't sure. So i would be -1 and it would try ...

  1. #16
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    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
    213
    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,185
    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
    213
    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.

Page 2 of 2 FirstFirst 12
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, 09: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21