Thread: pointers

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    30

    pointers

    ok,
    say x and y are pointers to mem loc 500.
    what does the stmt-
    y++=x++ do;

    where do x and y point now?why?
    apparently they point to the same loc but i dunno why?
    Last edited by eklavya8; 01-03-2009 at 03:21 PM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Well as posted, it doesn't seem to make any sense.

    But things like
    *dst++ = *src++;
    is a common way of copying a block of data from src to dst, in such a way that data is copied, and the pointers advance at the same time.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    30
    yes i thought so too,but as i mentioned the pointers dont seem to change there current location even after the statement.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Well, you can't assign to y++, so anything can happen. But if there wasn't an error, then yes x and y would both move forward.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. Replies: 4
    Last Post: 12-10-2006, 07:08 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM