class: title # Structs, Unions, and Enums ## CSC 161 – February 17, 2026 --- # Agenda for Today 1. Department Events 2. Upcoming Work 3. Code Cleanup 4. Discussion 5. Lab 6. Wrap Up --- # Department Events ## CS Table: Open Source and LLMs .indent[ Tuesday, February 17th at noon in JRC 224C ] ## CS Extra: Tarski Lower Bounds from Multi-Dimensional Herringbones .indent[ Speaker: Reed Phillips, Purdue University Thursday, February 19th at 4:15pm in Noyce 3821 Snacks available in the CS Commons at 4pm ] You can find a complete list of token events and submit more at
. --- class: section blue # Upcoming Work --- # Week 4 Lab Report **Due:** Tonight by 10:00pm See last week's class slides for the list of exercises you should submit to gradescope. Make sure you follow the most recent code style requirements we've discussed in class. --- # Week 5 Quiz As usual, we'll have a quiz on Thursday. The quiz will last 10 minutes, and will focus on: 1. Structures 2. Enums 3. Binary Integer Representation (unsigned only) Signed integer and floating point representations **will not** appear on Thursday's quiz. --- # Homework: Connect Four **Due:** Thursday, February 26th ## Questions _None so far_ If you need to work on the assignment from off campus you can access a MathLAN session by going to
. --- class: section blue # Code Cleanup --- # Code Cleanup How can we make this code better? ```c char x[128]; fgets(x, 128, stdin); printf("You typed %s\n", x); ``` --- class: section blue # Discussion --- # Discussion: Structs **Items for think, pair, share:** 1. What is a `struct`, and what is one scenario where you might want to use one? 2. What makes structs and arrays different in C? Do they have any similarities? 3. Write down a definition for the type `struct rectangle`, which will represent a rectangle. For any given rectangle, we will need to know its width and height so we can compute its area. --- # Discussion: Unions and Enums **Items for think, pair, share:** 1. What is an `enum` and what might you use it for? 2. What is a `union` and how is it different from a `struct`? 3. What is one situation where you might use a `union`? --- class: section blue # Lab --- class: section blue # Wrap Up --- # Wrap Up ## Lab Work Submit the completed `connect-four-stats.c` and `unions.c` source files (parts A through C) with this week's lab report. ## Mentor Session This week, our Wednesday mentor session will run from 8–9pm instead of the usual two hour block. ## Reading - **Binary Representation of Integers in C** - **Floating Point Representation**