C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28691
Number of posts: 94711

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
True or false Posted by Panasonic99 on 6 Aug 2005 at 6:42 PM
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......?
Report
Re: True or false Posted by Donotalo on 6 Aug 2005 at 7:57 PM
This message was edited by Donotalo at 2005-8-6 19:59:0

: 1. Two pointers that point to different arrays cannot be compared meaningfully.
Not clear. What kind of comparison?

: 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.
ya, u cant precisely 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.
Report
Re: True or false Posted by stober on 6 Aug 2005 at 8:47 PM
: : 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.
Report
Re: True or false Posted by AsmGuru62 on 7 Aug 2005 at 5:01 AM
: : : 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.
:
stober, two pointers - not the two contents of these pointers, so in my opinion - the answer is true.
Report
Re: True or false Posted by BitByBit_Thor on 7 Aug 2005 at 1:20 PM
This message was edited by BitByBit_Thor at 2005-8-7 13:21:35

: : : : 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.
: :
: stober, two pointers - not the two contents of these pointers, so in my opinion - the answer is true.
:

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
Report
Re: True or false Posted by stober on 7 Aug 2005 at 8:49 PM
: : : : : 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.
: : :
: : stober, two pointers - not the two contents of these pointers, so in my opinion - the answer is true.
: :
:
: 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.

Report
Re: True or false Posted by BitByBit_Thor on 8 Aug 2005 at 7:26 AM

: 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




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.