CSC209H5 Lecture 5: Struct

71 views3 pages

Document Summary

Csc209h5s - software programming and tools (winter 2018) //or struct player p1; p. name = josh ; struct player p1; struct player *ptr; ptr = &p (ptr->name)= josh ; (*ptr). name. // initialize it to represent the third baseman josh donaldson, He has hit 41 home runs. return 0 ; Has flexibility of things move (ie. grouping the ints together and/or unused bytes) home_runs (offset 40) position (offset 32) float int ptr (single pointer) name (offset 0) The *p refers to the name in the memory. At compile time, it knows the size of the package. There is no guarantee that the compiler will lay it out like this. The order of the struct can be different. When you define a struct (struct player p1), you are creating an instance of a struct. The stack will allocate a specific amount of space. p1 refers to the first part of the struct. struct player *, it can change the size in memory.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents