True or false - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# True or false

Posts: 140Member
1. Two pointers that point to different arrays cannot be compared meaningfully.
2. Because the name of an array is a pointer to the first element of the array, array names may be manipulated in precisely the same manner as pointers.

I'd say the first one is true and the second one is false......?

• Posts: 715Member
[b][red]This message was edited by Donotalo at 2005-8-6 19:59:0[/red][/b][hr]
: 1. Two pointers that point to different arrays cannot be compared meaningfully.
[purple]Not clear. What kind of comparison?[/purple]

: 2. Because the name of an array is a pointer to the first element of the array, array names may be manipulated in precisely the same manner as pointers.
[purple]ya, u cant [red]precisely[/red] use an array name as a pointer. u can treat the array name as a pointer. however, u cant change the value of that pointer, i.e., assign a new address to that pointer or pointer increment/decrement.[/purple]
• Posts: 9,765Member ✭✭✭
: : 1. Two pointers that point to different arrays cannot be compared meaningfully.

assume ptr1 = "James" and ptr2 = "Jones". Now use strcmp() to see if the two values are the same. So the answer to the this question is false because they can be compared.
• Posts: 6,519Member
: : : 1. Two pointers that point to different arrays cannot be compared meaningfully.
:
: assume ptr1 = "James" and ptr2 = "Jones". Now use strcmp() to see if the two values are the same. So the answer to the this question is false because they can be compared.
:
[blue][b]stober[/b], two [red]pointers[/red] - not the two [red]contents[/red] of these pointers, so in my opinion - the answer is true.[/blue]
• Posts: 2,444Member
[b][red]This message was edited by BitByBit_Thor at 2005-8-7 13:21:35[/red][/b][hr]
: : : : 1. Two pointers that point to different arrays cannot be compared meaningfully.
: :
: : assume ptr1 = "James" and ptr2 = "Jones". Now use strcmp() to see if the two values are the same. So the answer to the this question is false because they can be compared.
: :
: [blue][b]stober[/b], two [red]pointers[/red] - not the two [red]contents[/red] of these pointers, so in my opinion - the answer is true.[/blue]
:

1. The answer is "True" when you assume they point to different arrays.
If you leave that part out, than the meaning of checking it would be to see if they point to the same address.

2. Actually... the other way around is True: you can handle pointers as if they were an array.

Greets...
Richard
• Posts: 9,765Member ✭✭✭
: : : : : 1. Two pointers that point to different arrays cannot be compared meaningfully.
: : :
: : : assume ptr1 = "James" and ptr2 = "Jones". Now use strcmp() to see if the two values are the same. So the answer to the this question is false because they can be compared.
: : :
: : [blue][b]stober[/b], two [red]pointers[/red] - not the two [red]contents[/red] of these pointers, so in my opinion - the answer is true.[/blue]
: :
:
: 1. The answer is "True" when you assume they point to different arrays.
: If you leave that part out, than the meaning of checking it would be to see if they point to the same address.
:

I would still consider question 1 FALSE because you can make a meaningful comparison of two addresses -- to check if both pointers point to the same object.

• Posts: 2,444Member

: I would still consider question 1 FALSE because you can make a meaningful comparison of two addresses -- to check if both pointers point to the same object.
:
:

But in the question it is already stated that they DO NOT point to the same array (or object). *lol*

Greets...
Richard