2 Purpose: To show the use of pointers to structures
3 Dr. Purdum, Aug. 25, 2012
12 } myServicePeople, yourServicePeople;
13 void SetPhoneNumber(struct servicePeople *temp); // New signature declaration
16 Serial.print("myServicePeople lvalue: ");
17 Serial.print((int) &myServicePeople);
18 Serial.print(" yourServicePeople lvalue: ");
19 Serial.println((int) &yourServicePeople);
20 yourServicePeople.ID = 205;
21 Serial.print("myServicePeople.ID rvalue: ");
22 Serial.print(myServicePeople.ID);
23 Serial.print(" yourServicePeople.ID rvalue: ");
24 Serial.println(yourServicePeople.ID);
25 SetPhoneNumber(&myServicePeople); // Pass the lvalue
26 Serial.println("After assignment:");
27 Serial.print("myServicePeople.ID rvalue: ");
28 Serial.print(myServicePeople.ID);
29 Serial.print(" yourServicePeople.ID rvalue: ");
30 Serial.println(yourServicePeople.ID);
31 Serial.print("A servicePerson structure takes ");
32 Serial.print(sizeof(servicePeople));
33 Serial.println(" bytes of storage.");
34 Serial.print("myServicePeople.Phone rvalue: "); // New
35 Serial.println(myServicePeople.Phone); // New
36 Serial.print("yourServicePeople.Phone rvalue: ");
37 Serial.println(yourServicePeople.Phone);
43 // Lines below are changed
44 void SetPhoneNumber(struct servicePeople *temp)
46 (*temp).Phone = 2345678;