lab12_answers - Lab 12 Answer Sheet This lab is to be...

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

View Full Document Right Arrow Icon
Lab 12 Answer Sheet This lab is to be worked individually. Name: ___Jialing Ye____________________ Netid: _ye12_____________ Section: ___AYJ___ Part 1: Prelab notes. As with all prelabs/labs, if you are not sure of the answer you may go to any EWS lab on campus and check your results by using the gcc compiler, or you can ask anyone of the CS101 staff for help. 1. Write the code to create a structure definition for Student, a structure with two fields (members) , the first called netid (integer data type and a second called name (char array of size 64). Use typedef to name the structure type Student. ___typedef _struct {__________________________ ____int netid;______________ ____char[64] name;__________________________ _____}Student_________________________ Define your structure in such a way that you can declare a structure variable of type Student as follows: Student x ; 2. Now suppose we declare an array of Student structures as follows: Student students[10]; Remember array indexing begins with 0 in C. (a) Write a _single_ line of C code to assign the name "Michael Jordan"to thename member(field) of the *fifth* element of the array students. Hint: use the strcpy function. __strcpy(students[4].name, “Micheal Jordan”);______________________________________________________ (b) Write a _single_ line of C code to assign the value of the name member(field) in the *fifth* element of the students array to the name member(field) of *ninth* element of the students array. ___strcpy ( students[8].name, students[4].name);_____________________________________________________
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/19/2012 for the course CS 101 taught by Professor Gambill during the Spring '08 term at University of Illinois, Urbana Champaign.

Page1 / 6

lab12_answers - Lab 12 Answer Sheet This lab is to be...

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

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