We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

unsigned short

jtm082698
jtm082698 asked
on
Medium Priority
400 Views
Last Modified: 2010-04-02
I want to go back and forth from an unsigned short (temp) as a pointer to just an unsigned short (num), but ....
temp = (unsigned short*)num;
doesn't work or vice versa.
Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
Any of these should work:

temp = #

*temp = num;

num = *temp;

Commented:
The only work if temp is a pointer to the same type that num is.  I'm guessing that is not the case.

Commented:
Hmmm.  As I re-read I'm beginning to wonder if Eric is right.  If num is an unsigned short and temp is just a pointer to an unsigned short, then you should just do

temp = &num.

The "&" means "generate a pointer to" the item on the right.  If this is what you need, you should reject my answer and award the points to Eric.

Author

Commented:
Thanks for putting me on the right track, it was the ole "can't see the forest for the trees" type thing.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.