Programming with C

⌘K
  1. Home
  2. Docs
  3. Programming with C
  4. Functions and Pointers
  5. Pointer Arithmetic
  6. Pointer Comparison

Pointer Comparison

Pointer Comparison (Relational Operation)

The following operations can be performed on pointers

Example

#include<stdio.h>
int main()
{
	int *ptr1 = (int *) 2000;
	int *ptr2 = (int *) 2002;
	int r;
	r = ptr1 != ptr2;
	if(r == 0)
	{
		printf("Both are equal");
	}
	else
	{
		printf("Both are not equal");
	}
	return 0;
}

Output

Both are not equal

Views: 0

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments