Thread: pointer problem

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    1

    pointer problem

    Hi, I'm relatively new to this (still working my way through the textbooks!) and I'm having a bit of trouble with the following pointer:


    unsigned long int step, win_sum;
    float lacu_index, cal_lacu();
    long int win_size;
    unsigned char *store,*win_inside ;
    long address1,address2;
    fpos_t *img_start, *win_start;
    img_start = &address1;
    win_start = &address2;


    I've been going over this for hours now and I still dunno whats up. Any suggestions would be really greatful.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Do you know the basics of pointers? Pointers are just like other variables. They store values. The values that pointers store are the addresses of other variables. Other than that, they're exactly the same. So what you do is use the "address of" operator ( & ) to get the address of a variable, so you can stick that address in a pointer.

    Pointers also let you "dereference" them, using the asterix, to get the contents of whatever they point at.

    What's happening here is that you're taking the address of two longs and sticking those addresses into two different variables, of type "pointer to fpos_t".

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    Quote Originally Posted by gaulter
    Hi, I'm relatively new to this (still working my way through the textbooks!) and I'm having a bit of trouble with the following pointer:


    unsigned long int step, win_sum;
    float lacu_index, cal_lacu();
    long int win_size;

    unsigned char *store,*win_inside ;
    long address1, address2;
    fpos_t *img_start, *win_start;

    img_start = &address1;
    win_start = &address2;

    I've been going over this for hours now and I still dunno whats up. Any suggestions would be really greatful.
    I may be wrong, but it looks like you have pointers that are supposed to be pointing to variables of type "fpos_t", but it's actually pointing to a long. I don't see "fpos_t" defined anywhere, though...
    Last edited by Krak; 01-27-2005 at 04:46 PM.

  4. #4
    .
    Join Date
    Nov 2003
    Posts
    307
    fpos_t is a typedef - an alias for a datatype.

    For most file systems fpos_t is an unsigned long (or whatever datatype will the max possible bytes in a file)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointer to pointer realloc problem
    By prakash0104 in forum C Programming
    Replies: 14
    Last Post: 04-06-2009, 08:53 PM
  2. Another pointer problem
    By mikahell in forum C++ Programming
    Replies: 21
    Last Post: 07-20-2006, 07:37 PM
  3. Pointer problem
    By mikahell in forum C++ Programming
    Replies: 5
    Last Post: 07-20-2006, 10:21 AM
  4. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  5. pointer problem
    By DMaxJ in forum C Programming
    Replies: 4
    Last Post: 06-11-2003, 12:14 PM