Two pointers that point to different arrays cannot be compared meaningfully.
That's false right? because they can be compared in the same manner as integers are correc? if i am wrong please explain y or if u have anything to add please do!!!

Recommended Answers

All 4 Replies

One reason to compare pointers is to compare two pointers for equality (or inequality) to determine if they are pointing to the same thing, or not. Or if a pointer is pointing to anything at all (ie. ptr != NULL ).

Otherwise, using > or < comparison, it's kind of like comparing "123 Main St" (a real address in your town) to "125 Main St" (the next address down the block.) Does that tell you anything about the buildings that may be in those two locations? Single family house or 10-story apartment building? Run down house worth $10K or a mansion worth $10M?

The only way in which the data pointed to by array pointers can be compared in any meaningful way is if they are char* and you use one of the strcmp( ) comparison functions.

hey thx for your learning pointers in my comp sci class and at a first look i was like ???? but know im beginning to get the hang of it but u helped alot thx

I know this is a few days old but heres a good tutorial I like to show my intro students. Hope it helps.

I know this is a few days old but heres a good tutorial I like to show my intro students. Hope it helps.


A pointer, unlike a variable, is actually an address.

A pointer variable is certainly a variable.

sizeof(char) returns the size of a char(typically 1 byte)

Always 1 byte, not 'typically'

remember that array is a pointer to the first element of the array.

An array is not a pointer.

Pointer arithmetic is still very valid for void pointers.


A null pointer is a pointer that points to nothing.

A null pointer is guaranteed to compare unequal to a pointer to any object or function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.