Thread: adding pointers?

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    10

    adding pointers?

    Hello everybody

    I have a problem when I try to add two pointers, I explain myself: The code below is the result of "compiling" another code portion using a compiler I'm doing. I need the code has that structure, something like a intermediate code that must be compiled by gcc.

    Code:
    #include <stdio.h>
    
    int main() {
    void *d;
    d =(int*) 0;
    void *s;
    s =(int*) 0;
    int _VAR3 = (int*) s + d;
    _VAR3 = _VAR3 ;
    void *a;
    a =(int*) _VAR3;
    return 0;
    }
    The problem is the 8th line when i try to add two pointers, how can i do that without change so muche the structure of my code?

    Thank you so much

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Except you can't add two pointers in C.
    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
    Dec 2006
    Posts
    10
    but.. could I get their contents and add them or anything else?

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by ayoros View Post
    but.. could I get their contents and add them or anything else?
    yes you can
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    Registered User
    Join Date
    Dec 2006
    Posts
    10
    fixed
    Last edited by ayoros; 06-23-2007 at 04:45 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adding arrays with pointers - help
    By chip.litch in forum C Programming
    Replies: 2
    Last Post: 10-02-2008, 11:07 PM
  2. Arrays, pointers and strings
    By Apropos in forum C++ Programming
    Replies: 12
    Last Post: 03-21-2005, 11:25 PM
  3. 2D Array of Pointers
    By Slavakion in forum C++ Programming
    Replies: 12
    Last Post: 03-31-2004, 05:05 PM
  4. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 06:58 PM