By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,717 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

Output of int pointer manipulation.

P: 29
Expand|Select|Wrap|Line Numbers
  1. int *found =new int
  2.   *found = *found + 3
  3.   std::cout<<"found_"<<*found<<endl;
is the output correct at "*found"
Jun 15 '07 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 4,677
int *found =new int
*found = *found + 3

is the output correct at "*found"
What do you mean "correct"?

Aside of you never terminating the first two statements/lines, you also never assign a value to found. This means that when it is initalized, it takes on the value of whatever is in the memory it is assigned, it becomes a junk or garbage variable.

Edit::I'm not sure about the legality of the pointer manipulation you are doing. It looks okay offhand, but I'm not in a position to be able to check it. I'd recommend throwing it in a compiler - then you'd be able to see the "undefined behavior" or see if those are legal declarations/manipulations.
Jun 15 '07 #2

Expert Mod 2.5K+
P: 4,677
And please have a look at the Posting Guidelines, specifically the parts about using code tags, asking specific questions, and using good thread titles. Thanks!
Jun 15 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.