Thread: Pointers

  1. #1
    Registered User
    Join Date
    Jul 2004


    Well, i'm new but here's my problem

    __int16 PointerControl::ReadShort()
    	__int16 *data;
    	data = pointer;
    	pointer += sizeof(data);
    	return *data;
    pointer is a int, and i want to return the short value at the address of pointer.

    but this ^^ doesn't work, any suggestions?

  2. #2
    Registered User
    Join Date
    Mar 2002

    data = &pointer;

  3. #3
    Super Moderator
    Join Date
    Sep 2001
    Unless pointer is global and decalred somewhere else, it's not declared. You need to allocate space for it. Also, I'm not too sure what you're trying to do here. Either you need to rename your variables, or reorganize the equations. Right now it looks like "data" is a pointer and "pointer" is some data. And I don't think you need sizeof(data). pointer++ would work because C/C++ automatically scales the increments to the size of the variable.

  4. #4
    Registered User
    Join Date
    Nov 2001
    One solution is dynamic allocation.


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. function pointers
    By benhaldor in forum C Programming
    Replies: 4
    Last Post: 08-19-2007, 10:56 AM
  3. Request for comments
    By Prelude in forum A Brief History of
    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