lec12

Lec12 - Goto Exceptions and Assembly in C CS 2022 Introduction to C Instructor Hussam Abu-Libdeh Cornell University(based on slides by Saikat Guha

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Goto, Exceptions, and Assembly in C CS 2022: Introduction to C Instructor: Hussam Abu-Libdeh Cornell University (based on slides by Saikat Guha) Fall 2009, Lecture 12 Goto, Exceptions, and Assembly in C CS 2022, Fall 2009, Lecture 12
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Switch Statement I N-way if (N > 2), but equality check only I Only integers I But then many things in C are glorified integers I Notably, enums Goto, Exceptions, and Assembly in C CS 2022, Fall 2009, Lecture 12
Background image of page 2
Switch Statement enum days {Sun, Mon, Tue, Wed, Thu, Fri, Sat}; ... enum days day = . ..; switch (day) { case Sat: ... break; case Sun: ... break; case Mon: printf("Sounds like someone has a case of the Mondays.\n"); case Wed: case Fri: ... break; default: ... Goto, Exceptions, and Assembly in C CS 2022, Fall 2009, Lecture 12
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Goto I Unstructured control flow I (unlike if , switch , for etc.) I Evil I Except when it’s not I Especially, when it is the cleanest Goto, Exceptions, and Assembly in C CS 2022, Fall 2009, Lecture 12
Background image of page 4
Goto ... goto foo; ... foo: ... Goto, Exceptions, and Assembly in C CS 2022, Fall 2009, Lecture 12
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Goto Extremely useful for I breaking out of deeply nested loops I handling errors and exceptions I by writing code that cleans up resources in reverse
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 8
Background image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 03/10/2011.

Page1 / 9

Lec12 - Goto Exceptions and Assembly in C CS 2022 Introduction to C Instructor Hussam Abu-Libdeh Cornell University(based on slides by Saikat Guha

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online