pointers

This is a discussion on pointers within the C Programming forums, part of the General Programming Boards category; ok, say x and y are pointers to mem loc 500. what does the stmt- y++=x++ do; where do x ...

  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 02:21 PM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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,185
    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, 06:08 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 12:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21