Solved

Pointers

Posted on 1998-10-06
3
194 Views
Last Modified: 2010-04-01
variable type a;

What should be the variable type(say,int/char/char* etc.)so that,
a = &a =*a = same output/result?.
That is,what should be then the variablke type of a.
0
Comment
Question by:tmmet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Expert Comment

by:Booth882
ID: 1174604
is this a riddle?
0
 
LVL 1

Accepted Solution

by:
Booth882 earned 0 total points
ID: 1174605
there is no general type that would accomplish this.

but if you have an int that contains a hexidecimal value equal to its address this would be true.

    int AnInteger;

    AnInteger = &AnInteger;

if you did this then your statement

    AnInteger  ==  &AnInteger  ==  *AnInteger.

would be true.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1174606
a(){
    printf("%d %d %d\n",a==*a,a==&a,&a==*a);
}

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

634 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question