]> git.piffa.net Git - arduino/blob - books/beginning_c_code/Chapter10/Listing10_2/Listing10_2.ino
first commit
[arduino] / books / beginning_c_code / Chapter10 / Listing10_2 / Listing10_2.ino
1 /* 
2   Purpose: To show the use of the dot operator
3   Dr. Purdum, Aug. 25, 2012
4 */
5
6
7 struct servicePeople {
8   int ID;
9   char Name[20];
10   char PW[10];
11   long Phone;
12 } myServicePeople, yourServicePeople;
13 struct servicePeople SetPhoneNumber(struct servicePeople temp);        // New
14 void setup() {
15   Serial.begin(9600);
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   myServicePeople = SetPhoneNumber(yourServicePeople);                 // Changed
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.print(myServicePeople.Phone);                       // New 
36
37 void loop(){
38
39 }
40 // All lines below are new
41 struct servicePeople SetPhoneNumber(struct servicePeople temp)
42 {
43   temp.Phone = 2345678;
44   return temp;
45 }
46 \r