PointerEquality

PointerEquality - if (p1 == p3) { cout...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> using namespace std ; int main() { int x = 1, y = 2, z = 3 ; int *p1, *p2, *p3 ; p1 = & x ; p2 = & y ; if (p1 == p2) { cout << "p1 == p2" << endl ; } else { cout << "p1 != p2" << endl ; } if (*p1 == *p2) { cout << "*p1 == *p2" << endl ; } else { cout << "*p1 != *p2" << endl ; } *p1 = 2 ; if (p1 == p2) { cout << "p1 == p2" << endl ; } else { cout << "p1 != p2" << endl ; } if (*p1 == *p2) { cout << "*p1 == *p2" << endl ; } else { cout << "*p1 != *p2" << endl ; } p3 = p1 ;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (p1 == p3) { cout &lt;&lt; &quot;p1 == p3&quot; &lt;&lt; endl ; } else { cout &lt;&lt; &quot;p1 != p3&quot; &lt;&lt; endl ; } if (*p1 == *p3) { cout &lt;&lt; &quot;*p1 == *p3&quot; &lt;&lt; endl ; } else { cout &lt;&lt; &quot;*p1 != *p3&quot; &lt;&lt; endl ; } char s1 = &quot;abc&quot; ; char s2 = &quot;abc&quot; ; if (*s1 == *s2) { cout &lt;&lt; &quot;*s1 == *s2&quot; &lt;&lt; endl ; } else { cout &lt;&lt; &quot;*s1 != *s2&quot; &lt;&lt; endl ; } char *s3 ; s3 = s2 ; if (*s3 == *s2) { cout &lt;&lt; &quot;*s3 == *s2&quot; &lt;&lt; endl ; } else { cout &lt;&lt; &quot;*s3 != *s2&quot; &lt;&lt; endl ; } }...
View Full Document

Page1 / 2

PointerEquality - if (p1 == p3) { cout...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online