]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
(no commit message)
authorMarno007 <Marno007@web>
Thu, 22 Mar 2018 10:12:40 +0000 (06:12 -0400)
committeradmin <admin@branchable.com>
Thu, 22 Mar 2018 10:12:40 +0000 (06:12 -0400)
doc/sandbox.mdwn

index 7a755ee029bd9863f4f9a6cdb8b0c6cafb466d13..dc0aebf2dd4ce4cc083761669d376771a292da25 100644 (file)
@@ -226,3 +226,25 @@ Testing. Test. 試験として書き込みします。
 test
 
 I must **emphasise** this.
+
+
+// more pointers
+#include <iostream>
+using namespace std;
+
+int main ()
+{
+  int firstvalue = 5, secondvalue = 15;
+  int * p1, * p2;
+
+  p1 = &firstvalue;  // p1 = address of firstvalue
+  p2 = &secondvalue; // p2 = address of secondvalue
+  *p1 = 10;          // value pointed to by p1 = 10
+  *p2 = *p1;         // value pointed to by p2 = value pointed to by p1
+  p1 = p2;           // p1 = p2 (value of pointer is copied)
+  *p1 = 20;          // value pointed to by p1 = 20
+  
+  cout << "firstvalue is " << firstvalue << '\n';
+  cout << "secondvalue is " << secondvalue << '\n';
+  return 0;
+}