Speed of pointers vs. speed of arrays/structs

This is a discussion on Speed of pointers vs. speed of arrays/structs within the C Programming forums, part of the General Programming Boards category; Originally Posted by laserlight Could you elaborate? A pointer is of a different type from a pointer to itself, so ...

  1. #31
    Registered User
    Join Date
    Feb 2008
    Posts
    145
    Quote Originally Posted by laserlight View Post
    Could you elaborate? A pointer is of a different type from a pointer to itself, so how can it point to itself unless there is an error in the code?

    I suspect that the example is a strawman to begin with since it seems to deal with a loop index while iterating with a pointer, whereas there is the idiom of using the pointer to iterate directly.
    Not sure, but I think he was point that maybe situation where *p++ = &p, but I think more on it, I don't see anythinkg with sense.

  2. #32
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You would use it as a parameter to functions. There's a couple of examples here:
    http://www.devx.com/tips/Tip/13825

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #33
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,650
    Not sure, but I think he was point that maybe situation where *p++ = &p, but I think more on it, I don't see anythinkg with sense.
    Indeed, because if *p is of type T, then p is of type T*, and &p is of type T**, so that statement assigns a T** to a T, which is clearly a mistake.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  2. moving pointers to pointers
    By Benzakhar in forum C++ Programming
    Replies: 9
    Last Post: 12-27-2003, 07:30 AM
  3. pointers to pointers within structs
    By Lord_azrael99 in forum C Programming
    Replies: 2
    Last Post: 08-28-2003, 04:29 AM
  4. Pointers pointers pointers....
    By G'n'R in forum C Programming
    Replies: 11
    Last Post: 11-02-2001, 01:02 AM
  5. Pointers pointers pointers...
    By SMurf in forum C Programming
    Replies: 8
    Last Post: 10-23-2001, 04:55 PM

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