Exploring Nested Structures in ECE Application Programming

eece 2160 n.w
1 / 6
Embed
Share

Dive into the lecture on nested structures in ECE application programming, understanding how structures can contain other structures. Learn about the necessary dot operators to access fields within nested structures, complete specified functions for the Name and SINew structures, and explore exercises related to printing, reading, and searching for student information. Be prepared for the upcoming program deadlines and exam reviews.

  • ECE Programming
  • Nested Structures
  • Student Information
  • Programming Functions
  • Exam Review

Uploaded on | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. EECE.2160 ECE Application Programming Instructors: Dr. Michael Geiger Spring 2018 Lecture 27 Nested structures

  2. Lecture outline Announcements/reminders Program 5 regrades due today Program 7 due Friday, 4/13 Today s lecture Nested structures PE4: Structures 4/16/2025 2 ECE Application Programming: Lecture 27

  3. Nested structures Structures can contain other structures: typedef struct { char first[50]; char middle; char last[50]; } Name; // First name // Middle initial // Last name typedef struct { Name sname; unsigned int ID; double GPA; } SINew; // Student name // ID # // Grade point Will need multiple dot operators to access field within nested structure Given SINew s1; s1.sname Name structure within s1 s1.sname.middle middle initial of name within s1 4/16/2025 3 ECE Application Programming: Lecture 27

  4. PE4 (Structures) Given header files, main program Complete specified functions For the Name structure void printName(Name *n): Print the name pointed to by n, using format <first> <middle>. <last> void readName(Name *n): Prompt for and read a first, middle, and last name, and store them in the structure pointed to by n SINew functions on next slide 4/16/2025 4 ECE Application Programming: Lecture 27

  5. Todays exercise (continued) Given header files, main program Complete specified functions Name functions on previous slide For the SINew structure void printStudent(SINew *s): Print information about the student pointed to by s void readStudent(SINew *s): Prompt for and read information into the student pointed to by s void printList(SINew list[], int n): Print the contents of an array list that contains nStudentInfo structures int findByLName(SINew list[], int n, char lname[]): Search for the student with last name lname in the array list. Return the index of the structure containing that last name, or -1 if not found int findByID(SINew list[], int n, unsigned int sID): Search for the student with ID # sID in the array list. Return the index of the structure containing that last name, or -1 if not found 4/16/2025 5 ECE Application Programming: Lecture 27

  6. Final notes Next time Exam 2 Review Reminders: Program 5 regrades due Monday, 4/9 Program 6 due today Program 7 due Friday, 4/13 4/16/2025 6 ECE Application Programming: Lecture 27

More Related Content