Well Guys, M here just to show wats hpning.. Have your own views..
1> Everything is right till While loop.. I mean p1 pointing to the heap of the address of the String "Name" , P1 getting 20 bytes of memory chunk and so on.. So here we go now. As this Stupid looking while is culprit here as it is coping the content of one pointer to other as well as moving itself forward. So What happened when While exits, is p1 points to NULL and is copied successfully to p1 but due to post incrementation of p1 and p2 both are momentary lost and wen't beyond the '\0' character.. So when U print it it goes printing all the rest of 20 character bytes losing it front values. hope U guys have u r clear picture now. 2> Is compiler dependent but can be kinda predictable. Reason:- 1> STL says the two point rule as someone stated above. Coz they feared if this rule does not followed that big chaos might happen but here its simple and kinda predictable. 2> Anyone who have worked or know a bit of Embedded can easily tell how the hardware operated on this equation. Prem On Wed, Jul 25, 2012 at 9:10 PM, deepikaanand <swinyanand...@gmail.com>wrote: > @ jatin > then there is something wrong I executed d same prog which I have pasted > here...it was giving me the correct answer and for the second qs has no > absolute answer it depends on compiler > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/algogeeks/-/TOSg6xbES24J. > > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.