Thread: Globla and local variables

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    75
    It's printing 0 infinitely because you're not passing the incremented value to test in the recursive call.

    To make it work use
    Code:
    test(++count); /*pre-increment*/
    instead of
    Code:
    test(count++); /*post-increment*/
    EDIT: Note that a new copy of the variable is created at each function call.
    Last edited by noodles; 11-18-2006 at 10:48 PM.

Popular pages Recent additions subscribe to a feed