byte array pointer question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andy.dreistadt@gmail.com

    #1

    byte array pointer question

    Hi all,

    I know this is a pretty easy question for most, but I haven't touched
    C++ in 5 years and am a bit rusty.

    I have the following set-up:

    my_function(BYT E *buf,WORD len)
    {
    //some stuff

    int num_bytes = serialSendRcv(0 , buf, len, 5000);

    //....more stuff
    }


    The problem is that the first byte of the buf array (buf[0]) is a
    filter byte that I no longer need and do not want to pass to the
    serialSendRcv() method. Instead, I would like to send it the array
    containing buf[1]..buf[len]. I heard the best way to do this is to
    dereference the array and increment the address, but I can't remember
    how that's done.

    Thanks in advance for any help you can give,

    Andy

  • Victor Bazarov

    #2
    Re: byte array pointer question

    andy.dreistadt@ gmail.com wrote:[color=blue]
    > I know this is a pretty easy question for most, but I haven't touched
    > C++ in 5 years and am a bit rusty.
    >
    > I have the following set-up:
    >
    > my_function(BYT E *buf,WORD len)
    > {
    > //some stuff
    >
    > int num_bytes = serialSendRcv(0 , buf, len, 5000);[/color]

    What you are asking below is

    int num_bytes = serialSendRcv(0 , buf + 1, len - 1, 5000);

    I have no idea what '0' and '5000' are supposed to mean and whether
    they need to change as well.
    [color=blue]
    >
    > //....more stuff
    > }
    >
    >
    > The problem is that the first byte of the buf array (buf[0]) is a
    > filter byte that I no longer need and do not want to pass to the
    > serialSendRcv() method. Instead, I would like to send it the array
    > containing buf[1]..buf[len]. I heard the best way to do this is to
    > dereference the array and increment the address, but I can't remember
    > how that's done.[/color]

    Victor

    Comment

    • andy.dreistadt@gmail.com

      #3
      Re: byte array pointer question

      Victor,

      It worked! Thanks again for your help.

      Andy

      Comment

      Working...