]> git.piffa.net Git - arduino/blob - books/beginning_c_code/Chapter09/Listing9_1/Listing9_1.ino
first commit
[arduino] / books / beginning_c_code / Chapter09 / Listing9_1 / Listing9_1.ino
1 /*
2   Purpose: Illustrate pointer arithmetic
3   Dr. Purdum, August 20, 2012
4  */
5 #include <string.h>
6 void setup() {                
7   Serial.begin(9600);   
8 }
9
10
11 void loop() {
12   char buffer[50];
13   char *ptr;
14   int i;
15   int length;
16   
17   strcpy(buffer, "When in the course of human events");
18   ptr = buffer;
19   length = strlen(buffer);
20   Serial.print("The lvalue for ptr is: ");
21   Serial.print((unsigned int)&ptr);
22   Serial.print(" and the rvalue is ");
23   Serial.println((unsigned int)ptr);
24   while (*ptr) {
25     Serial.print(*ptr++);
26   }
27
28   Serial.flush();  // Make sure all the data is sent...
29   exit(0);
30  
31 }
32 \r