Nested if & Stack

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aneeshazeez
    New Member
    • Jan 2009
    • 2

    Nested if & Stack

    Will the use of nested if in C programming impact the stack usage?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by aneeshazeez
    Will the use of nested if in C programming impact the stack usage?
    No, a few (conditional) jumps take care of it all.

    kind regards,

    Jos

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      Originally posted by aneeshazeez
      Will the use of nested if in C programming impact the stack usage?
      Originally posted by Jos
      No, a few (conditional) jumps take care of it all.
      From a practical point of view, Jos is right ... the nested if's themselves won't cause any stack usage. However, the statements within the if/the/else blocks could use stack (automatic variable declarations, function calls, etc).

      From a pedantic point of view, the C Standard imposes no requirements on how an implementation makes use of stack. For that matter, the C Standard does not require that the implementation has a stack at all. So anything you learn about stack usage by your compiler could be invalid on another compiler.

      Comment

      Working...