Copying Few Octets from Vector

Discussion in 'C++' started by smilesonisamal@gmail.com, Apr 10, 2009.

  1. Guest

    Hi all,
    I am facing difficulty in copying few octets from a vector to a
    buffer.

    typedef unsigned char uint8_t;
    I have a vector std::vector<uint8_t*> m_Data;
    which contains the following octets. I want to copy (30 74 64 230 0 8)
    to a buffer. I saw in the web and got code where iterator is used to
    copy all the octets not partial elements. How will I retrieve 6 octets
    from the vector? I am new to C++ and facing lot of problems in
    conversion. I tried a lot but couldnot succeed.Could anybody help me
    in this regard?
    Any example source code will be great help.

    Vector Elements
    -------------------------
    1 0 94 0 0 2 0 30 74 64 230 0 8 0 69 0 0 48 0 0 0 0 1 17 168 216 146
    223 158 3 2
    24 0 0 2 7 193 7 193 0 28 81 57 0 0 8 3 10 100 5 0 99 105 115 99 111 0
    0 0 146 2
    23 158 1

    Regards
    Soni
    , Apr 10, 2009
    #1
    1. Advertising

  2. wrote:
    > Hi all,
    > I am facing difficulty in copying few octets from a vector to a
    > buffer.


    What kind of difficulty?

    > typedef unsigned char uint8_t;
    > I have a vector std::vector<uint8_t*> m_Data;
    > which contains the following octets. I want to copy (30 74 64 230 0 8)
    > to a buffer. I saw in the web and got code where iterator is used to
    > copy all the octets not partial elements. How will I retrieve 6 octets
    > from the vector? I am new to C++ and facing lot of problems in
    > conversion.


    "In conversion"? To and from what?

    > I tried a lot but couldnot succeed.Could anybody help me
    > in this regard?


    Yes, we can help. What have you tried? Post your code.

    > Any example source code will be great help.


    Show us yours and we'll show you ours. Oh, and while you're at it,
    check out FAQ 5.2, please. You can find the FAQ list here:
    http://www.parashift.com/c -faq-lite/

    >
    > Vector Elements
    > -------------------------
    > 1 0 94 0 0 2 0 30 74 64 230 0 8 0 69 0 0 48 0 0 0 0 1 17 168 216 146
    > 223 158 3 2
    > 24 0 0 2 7 193 7 193 0 28 81 57 0 0 8 3 10 100 5 0 99 105 115 99 111 0
    > 0 0 146 2
    > 23 158 1


    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Apr 10, 2009
    #2
    1. Advertising

  3. Guest

    On Apr 10, 6:25 pm, Victor Bazarov <> wrote:
    > wrote:
    > > Hi all,
    > >     I am facing difficulty in copying few octets from a vector to a
    > > buffer.

    >
    > What kind of difficulty?
    >
    > > typedef unsigned char uint8_t;
    > > I have a vector std::vector<uint8_t*>   m_Data;
    > > which contains the following octets. I want to copy (30 74 64 230 0 8)
    > > to a buffer. I saw in the web and got code where iterator is used to
    > > copy all the octets not partial elements. How will I retrieve 6 octets
    > > from the vector? I am new to C++ and facing lot of problems in
    > > conversion.

    >
    > "In conversion"?  To and from what?
    >
    >  > I tried a lot but couldnot succeed.Could anybody help me
    >
    > > in this regard?

    >
    > Yes, we can help.  What have you tried?  Post your code.
    >
    > > Any example source code will be great help.

    >
    > Show us yours and we'll show you ours.  Oh, and while you're at it,
    > check out FAQ 5.2, please.  You can find the FAQ list here:http://www.parashift.com/c -faq-lite/
    >
    >
    >
    > > Vector Elements
    > > -------------------------
    > > 1 0 94 0 0 2 0 30 74 64 230 0 8 0 69 0 0 48 0 0 0 0 1 17 168 216 146
    > > 223 158 3 2
    > > 24 0 0 2 7 193 7 193 0 28 81 57 0 0 8 3 10 100 5 0 99 105 115 99 111 0
    > > 0 0 146 2
    > > 23 158 1

    >
    > V
    > --
    > Please remove capital 'A's when replying by e-mail
    > I do not respond to top-posted replies, please don't ask



    Hi,

    I have tried and could not succeed.

    std::vector<uint8_t*> m_Data;

    unsigned char*
    GetData(unsigned long octetOffset)
    {

    unsigned long bufferLength = m_Data.size() - octetOffset;
    uchar* buffer = new uchar[bufferLength];

    // Copy the packet data buffer
    const_iterator it = m_Data.begin() + octetOffset;

    int octet = 0;
    for (; it != m_Data.end(); ++it, ++octet)
    buffer[octet] = *it;


    return buffer;

    }

    Regards
    Soni
    , Apr 10, 2009
    #3
  4. wrote:
    > On Apr 10, 6:25 pm, Victor Bazarov <> wrote:
    >> wrote:
    >>> Hi all,
    >>> I am facing difficulty in copying few octets from a vector to a
    >>> buffer.

    >> What kind of difficulty?
    >>
    >>> typedef unsigned char uint8_t;
    >>> I have a vector std::vector<uint8_t*> m_Data;
    >>> which contains the following octets. I want to copy (30 74 64 230 0 8)
    >>> to a buffer. I saw in the web and got code where iterator is used to
    >>> copy all the octets not partial elements. How will I retrieve 6 octets
    >>> from the vector? I am new to C++ and facing lot of problems in
    >>> conversion.

    >> "In conversion"? To and from what?
    >>
    >> > I tried a lot but couldnot succeed.Could anybody help me

    >>
    >>> in this regard?

    >> Yes, we can help. What have you tried? Post your code.
    >>
    >>> Any example source code will be great help.

    >> Show us yours and we'll show you ours. Oh, and while you're at it,
    >> check out FAQ 5.2, please. You can find the FAQ list here:http://www.parashift.com/c -faq-lite/
    >>
    >>
    >>
    >>> Vector Elements
    >>> -------------------------
    >>> 1 0 94 0 0 2 0 30 74 64 230 0 8 0 69 0 0 48 0 0 0 0 1 17 168 216 146
    >>> 223 158 3 2
    >>> 24 0 0 2 7 193 7 193 0 28 81 57 0 0 8 3 10 100 5 0 99 105 115 99 111 0
    >>> 0 0 146 2
    >>> 23 158 1

    >> V
    >> --
    >> Please remove capital 'A's when replying by e-mail
    >> I do not respond to top-posted replies, please don't ask

    >
    >
    > Hi,
    >
    > I have tried and could not succeed.


    What exactly isn't working? Did you read the FAQ? If you haven't,
    please do, and pay close attention to FAQ 5.8.

    >
    > std::vector<uint8_t*> m_Data;
    >
    > unsigned char*
    > GetData(unsigned long octetOffset)
    > {
    >
    > unsigned long bufferLength = m_Data.size() - octetOffset;
    > uchar* buffer = new uchar[bufferLength];
    >
    > // Copy the packet data buffer
    > const_iterator it = m_Data.begin() + octetOffset;
    >
    > int octet = 0;
    > for (; it != m_Data.end(); ++it, ++octet)
    > buffer[octet] = *it;
    >
    >
    > return buffer;
    >
    > }


    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Apr 10, 2009
    #4
  5. Guest

    On Apr 10, 6:54 pm, Victor Bazarov <> wrote:
    > wrote:
    > > On Apr 10, 6:25 pm, Victor Bazarov <> wrote:
    > >> wrote:
    > >>> Hi all,
    > >>>     I am facing difficulty in copying few octets from a vector to a
    > >>> buffer.
    > >> What kind of difficulty?

    >
    > >>> typedef unsigned char uint8_t;
    > >>> I have a vector std::vector<uint8_t*>   m_Data;
    > >>> which contains the following octets. I want to copy (30 74 64 230 0 8)
    > >>> to a buffer. I saw in the web and got code where iterator is used to
    > >>> copy all the octets not partial elements. How will I retrieve 6 octets
    > >>> from the vector? I am new to C++ and facing lot of problems in
    > >>> conversion.
    > >> "In conversion"?  To and from what?

    >
    > >>  > I tried a lot but couldnot succeed.Could anybody help me

    >
    > >>> in this regard?
    > >> Yes, we can help.  What have you tried?  Post your code.

    >
    > >>> Any example source code will be great help.
    > >> Show us yours and we'll show you ours.  Oh, and while you're at it,
    > >> check out FAQ 5.2, please.  You can find the FAQ list here:http://www.parashift.com/c -faq-lite/

    >
    > >>> Vector Elements
    > >>> -------------------------
    > >>> 1 0 94 0 0 2 0 30 74 64 230 0 8 0 69 0 0 48 0 0 0 0 1 17 168 216 146
    > >>> 223 158 3 2
    > >>> 24 0 0 2 7 193 7 193 0 28 81 57 0 0 8 3 10 100 5 0 99 105 115 99 111 0
    > >>> 0 0 146 2
    > >>> 23 158 1
    > >> V
    > >> --
    > >> Please remove capital 'A's when replying by e-mail
    > >> I do not respond to top-posted replies, please don't ask

    >
    > > Hi,

    >
    > >   I have tried and could not succeed.

    >
    > What exactly isn't working?  Did you read the FAQ?  If you haven't,
    > please do, and pay close attention to FAQ 5.8.
    >
    >
    >
    >
    >
    > > std::vector<uint8_t*>   m_Data;

    >
    > > unsigned char*
    > > GetData(unsigned long octetOffset)
    > > {

    >
    > > unsigned long bufferLength = m_Data.size() - octetOffset;
    > > uchar* buffer = new uchar[bufferLength];

    >
    > >    // Copy the packet data  buffer
    > >   const_iterator it = m_Data.begin() + octetOffset;

    >
    > >    int octet = 0;
    > >    for (; it != m_Data.end(); ++it, ++octet)
    > >       buffer[octet] = *it;

    >
    > >    return buffer;

    >
    > > }

    >
    > V
    > --
    > Please remove capital 'A's when replying by e-mail
    > I do not respond to top-posted replies, please don't ask


    Actually I have written the code for copying the whole packets to the
    packet buffer. What I dont know is how to extract 6 octet from the
    position-0 in vector.
    , Apr 10, 2009
    #5
  6. wrote:
    > [..]
    > Actually I have written the code for copying the whole packets to the
    > packet buffer. What I dont know is how to extract 6 octet from the
    > position-0 in vector.


    Let me see if I understand you. You have a vector of elements, like
    several hundreds long, right? And you don't know how to get the first
    six elements from that vector? That can't be right. Again, I don't
    exactly understand what you're saying, most likely.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Apr 10, 2009
    #6
  7. * :
    > Hi all,
    > I am facing difficulty in copying few octets from a vector to a
    > buffer.
    >
    > typedef unsigned char uint8_t;
    > I have a vector std::vector<uint8_t*> m_Data;
    > which contains the following octets. I want to copy (30 74 64 230 0 8)
    > to a buffer. I saw in the web and got code where iterator is used to
    > copy all the octets not partial elements. How will I retrieve 6 octets
    > from the vector? I am new to C++ and facing lot of problems in
    > conversion. I tried a lot but couldnot succeed.Could anybody help me
    > in this regard?
    > Any example source code will be great help.
    >
    > Vector Elements
    > -------------------------
    > 1 0 94 0 0 2 0 30 74 64 230 0 8 0 69 0 0 48 0 0 0 0 1 17 168 216 146
    > 223 158 3 2
    > 24 0 0 2 7 193 7 193 0 28 81 57 0 0 8 3 10 100 5 0 99 105 115 99 111 0
    > 0 0 146 2
    > 23 158 1
    >
    > Regards
    > Soni


    Please explain your data structure.

    You have a vector of pointers.

    Is it the first pointer in the vector that points to the data listed above?

    How do you know the data size?

    Also, please explain exactly what you're trying to accomplish.


    Cheers & hth.,

    - Alf

    --
    Due to hosting requirements I need visits to <url: http://alfps.izfree.com/>.
    No ads, and there is some C++ stuff! :) Just going there is good. Linking
    to it is even better! Thanks in advance!
    Alf P. Steinbach, Apr 10, 2009
    #7
  8. Guest

    On Apr 10, 10:10 pm, "Alf P. Steinbach" <> wrote:
    > * :
    >
    >
    >
    > > Hi all,
    > >     I am facing difficulty in copying few octets from a vector to a
    > > buffer.

    >
    > > typedef unsigned char uint8_t;
    > > I have a vector std::vector<uint8_t*>   m_Data;
    > > which contains the following octets. I want to copy (30 74 64 230 0 8)
    > > to a buffer. I saw in the web and got code where iterator is used to
    > > copy all the octets not partial elements. How will I retrieve 6 octets
    > > from the vector? I am new to C++ and facing lot of problems in
    > > conversion. I tried a lot but couldnot succeed.Could anybody help me
    > > in this regard?
    > > Any example source code will be great help.

    >
    > > Vector Elements
    > > -------------------------
    > > 1 0 94 0 0 2 0 30 74 64 230 0 8 0 69 0 0 48 0 0 0 0 1 17 168 216 146
    > > 223 158 3 2
    > > 24 0 0 2 7 193 7 193 0 28 81 57 0 0 8 3 10 100 5 0 99 105 115 99 111 0
    > > 0 0 146 2
    > > 23 158 1

    >
    > > Regards
    > > Soni

    >
    > Please explain your data structure.
    >
    > You have a vector of pointers.
    >
    > Is it the first pointer in the vector that points to the data listed above?

    First pointer of vector points to first element of the vector.
    >
    > How do you know the data size?

    m_Data.size()
    >
    > Also, please explain exactly what you're trying to accomplish.


    Basically Iam trying to get the first 6 octets of the ethernet packet
    (destination mac address) from the packet(decimal format) and try to
    compare with the a different mac address. if they are same I need to
    do some more operation. All the octets are stored in a vector.
    >
    > Cheers & hth.,
    >
    > - Alf
    >
    > --
    > Due to hosting requirements I need visits to <url:http://alfps.izfree.com/>.
    > No ads, and there is some C++ stuff! :) Just going there is good. Linking
    > to it is even better! Thanks in advance!


    For Victor
    -----------
    Actually I found lot of examples in vector which traverses from begin
    to end. What I understand is a iterator traverses an object. Am I
    right? If I will have the code as below:

    for (it=m_Data.begin(); it<6; it++)
    Its gonna fail in compilation.Am I right?
    , Apr 10, 2009
    #8
  9. * :
    > On Apr 10, 10:10 pm, "Alf P. Steinbach" <> wrote:
    >> * :
    >>
    >>
    >>
    >>> Hi all,
    >>> I am facing difficulty in copying few octets from a vector to a
    >>> buffer.
    >>> typedef unsigned char uint8_t;
    >>> I have a vector std::vector<uint8_t*> m_Data;
    >>> which contains the following octets. I want to copy (30 74 64 230 0 8)
    >>> to a buffer. I saw in the web and got code where iterator is used to
    >>> copy all the octets not partial elements. How will I retrieve 6 octets
    >>> from the vector? I am new to C++ and facing lot of problems in
    >>> conversion. I tried a lot but couldnot succeed.Could anybody help me
    >>> in this regard?
    >>> Any example source code will be great help.
    >>> Vector Elements
    >>> -------------------------
    >>> 1 0 94 0 0 2 0 30 74 64 230 0 8 0 69 0 0 48 0 0 0 0 1 17 168 216 146
    >>> 223 158 3 2
    >>> 24 0 0 2 7 193 7 193 0 28 81 57 0 0 8 3 10 100 5 0 99 105 115 99 111 0
    >>> 0 0 146 2
    >>> 23 158 1
    >>> Regards
    >>> Soni

    >> Please explain your data structure.
    >>
    >> You have a vector of pointers.
    >>
    >> Is it the first pointer in the vector that points to the data listed above?

    > First pointer of vector points to first element of the vector.


    The first vector element points to itself?

    The first vector element points to the first element of some raw array?

    What?


    >> How do you know the data size?

    > m_Data.size()


    You have a vector of pointers.

    The number of pointers is quite likely not the size of your numerical data shown
    above.


    >> Also, please explain exactly what you're trying to accomplish.

    >
    > Basically Iam trying to get the first 6 octets of the ethernet packet
    > (destination mac address) from the packet(decimal format) and try to
    > compare with the a different mac address.


    What do you mean by "decimal format".


    Cheers & hth.,

    - Alf

    --
    Due to hosting requirements I need visits to <url: http://alfps.izfree.com/>.
    No ads, and there is some C++ stuff! :) Just going there is good. Linking
    to it is even better! Thanks in advance!
    Alf P. Steinbach, Apr 10, 2009
    #9
  10. James Kanze Guest

    On Apr 10, 3:18 pm, wrote:

    > I am facing difficulty in copying few octets from a vector to a
    > buffer.


    > typedef unsigned char uint8_t;
    > I have a vector std::vector<uint8_t*> m_Data;


    I'm not sure about the rest, but this vector doesn't contain
    octets; it contains pointers.

    > which contains the following octets.


    And none follow. So we have a vector which contains
    pointers, and there are no octets. So far, so good.

    > I want to copy (30 74 64 230 0 8) to a buffer.


    Where do these octets come from?

    > I saw in the web and got code where iterator is used to
    > copy all the octets not partial elements. How will I
    > retrieve 6 octets from the vector?


    If the vector contains pointers, you can't. All you can get
    from it is pointers.

    Supposing you have a vector of octets:
    std::vector< uint8_t > data ;
    *and* supposing that offset plus length are less than the
    size, you can copy the first length octets, starting from
    offset, using std::copy:
    std::copy( data.begin() + offset,
    data.begin() + offest + length,
    destination ) ;
    You'd best check that offset + length <= data.size()
    beforehand, though.

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
    James Kanze, Apr 10, 2009
    #10
  11. James Kanze Guest

    On Apr 10, 7:40 pm, wrote:
    > On Apr 10, 10:10 pm, "Alf P. Steinbach" <> wrote:
    > > * :
    > > > I am facing difficulty in copying few octets from a
    > > > vector to a buffer.


    > > > typedef unsigned char uint8_t;


    BTW: you shouldn't write this typedef yourself. You should
    get it from <stdint.h>.

    > > > I have a vector std::vector<uint8_t*> m_Data;
    > > > which contains the following octets. I want to copy
    > > > (30 74 64 230 0 8) to a buffer. I saw in the web and
    > > > got code where iterator is used to copy all the octets
    > > > not partial elements. How will I retrieve 6 octets
    > > > from the vector? I am new to C++ and facing lot of
    > > > problems in conversion. I tried a lot but couldnot
    > > > succeed.Could anybody help me in this regard?


    > > Please explain your data structure.


    > > You have a vector of pointers.


    You just explained it for him:).

    > > Is it the first pointer in the vector that points to the
    > > data listed above?


    > First pointer of vector points to first element of the
    > vector.


    That's not possible, since the first pointer in the vector
    has type uint8_t*, which is, of course, the same type as the
    elements in the vector. And to point to an element of this
    type, you'd need a uint8_t**.

    > > How do you know the data size?

    > m_Data.size()


    That's the number of pointers in the vector.

    > > Also, please explain exactly what you're trying to
    > > accomplish.


    > Basically Iam trying to get the first 6 octets of the
    > ethernet packet (destination mac address) from the
    > packet(decimal format) and try to compare with the a
    > different mac address. if they are same I need to do some
    > more operation. All the octets are stored in a vector.


    You're still not very clear. First, do you have octets, or
    decimal format? And what is the data structure which holds
    them? If all of the octets are stored in a vector, then you
    have octets, and not decimal format (which is text). And
    that vector has the type std::vector< uint8_t >. And
    getting the first six is trivial, using begin() and begin()
    + 6. (Provided, of course, that there are 6 or more octets
    in the vector.)

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
    James Kanze, Apr 10, 2009
    #11
  12. Guest

    On Apr 11, 12:34 am, James Kanze <> wrote:
    > On Apr 10, 7:40 pm, wrote:
    >
    > > On Apr 10, 10:10 pm, "Alf P. Steinbach" <> wrote:
    > > > * :
    > > > > I am facing difficulty in copying few octets from a
    > > > > vector to a buffer.
    > > > > typedef unsigned char uint8_t;

    >
    > BTW: you shouldn't write this typedef yourself.  You should
    > get it from <stdint.h>.
    >
    > > > > I have a vector std::vector<uint8_t*>   m_Data;
    > > > > which contains the following octets. I want to copy
    > > > > (30 74 64 230 0 8) to a buffer. I saw in the web and
    > > > > got code where iterator is used to copy all the octets
    > > > > not partial elements. How will I retrieve 6 octets
    > > > > from the vector? I am new to C++ and facing lot of
    > > > > problems in conversion. I tried a lot but couldnot
    > > > > succeed.Could anybody help me in this regard?
    > > > Please explain your data structure.
    > > > You have a vector of pointers.

    >
    > You just explained it for him:).
    >
    > > > Is it the first pointer in the vector that points to the
    > > > data listed above?

    > >  First pointer of vector points to first element of the
    > >  vector.

    >
    > That's not possible, since the first pointer in the vector
    > has type uint8_t*, which is, of course, the same type as the
    > elements in the vector.  And to point to an element of this
    > type, you'd need a uint8_t**.
    >
    > > > How do you know the data size?

    > > m_Data.size()

    >
    > That's the number of pointers in the vector.
    >
    > > > Also, please explain exactly what you're trying to
    > > > accomplish.

    > > Basically Iam trying to get the first 6 octets of the
    > > ethernet packet (destination mac address) from the
    > > packet(decimal format) and try to compare with the a
    > > different mac address. if they are same I need to do some
    > > more operation. All the octets are stored in a vector.

    >
    > You're still not very clear.  First, do you have octets, or
    > decimal format?  And what is the data structure which holds
    > them?  If all of the octets are stored in a vector, then you
    > have octets, and not decimal format (which is text).  And
    > that vector has the type std::vector< uint8_t >.  And
    > getting the first six is trivial, using begin() and begin()
    > + 6.  (Provided, of course, that there are 6 or more octets
    > in the vector.)


    I have a sequence of octets as mentioned in my earlier qs. I have
    stored it in a vector which contains series of octets.(uint_8*). I
    want to get the traverse through the series of octets from offset=0
    till the 6th element and compare with a mac address that i have
    already in a string format(00:00:00:00:00:01-> converted to
    string-48,48,ascii:))). I want to use strcmp/memcmp or something to
    compare once i extract 6 octets from the offset=0 from the sequence of
    octets from vector. If they are equal i want to do some operations.
    The octets are read from a binary file.
    Could you please help me in this regard? Some example code will be
    helpful for me.


    >
    > --
    > James Kanze (GABI Software)             email:
    > Conseils en informatique orientée objet/
    >                    Beratung in objektorientierter Datenverarbeitung
    > 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
    , Apr 12, 2009
    #12
  13. SG Guest

    On 12 Apr., 07:18, wrote:
    > On Apr 11, 12:34 am, James Kanze wrote:
    > > You're still not very clear.  First, do you have octets, or
    > > decimal format?  And what is the data structure which holds
    > > them?  If all of the octets are stored in a vector, then you
    > > have octets, and not decimal format (which is text).  And
    > > that vector has the type std::vector< uint8_t >.  And
    > > getting the first six is trivial, using begin() and begin()
    > > + 6.  (Provided, of course, that there are 6 or more octets
    > > in the vector.)

    >
    > I have a sequence of octets as mentioned in my earlier qs. I have
    > stored it in a vector which contains series of octets.(uint_8*).


    How?

    How's a sequence of pointers (uint_8*) a sequence of octets?

    > I
    > want to get the traverse through the series of octets from offset=0
    > till the 6th element and compare with a mac address that i have
    > already in a string format(00:00:00:00:00:01-> converted to
    > string-48,48,ascii:))). I want to use strcmp/memcmp or something to
    > compare once i extract 6 octets from the offset=0 from the sequence of
    > octets from vector.


    Understood.

    > [...] Could you please help me in this regard? Some example code
    > will be helpful for me.


    Indeed it would. Show some code --- because we don't have a clue about
    how you stored your MAC address in the vector of *pointers*.

    Cheers!
    SG
    SG, Apr 12, 2009
    #13
  14. James Kanze Guest

    On Apr 12, 7:18 am, wrote:
    > On Apr 11, 12:34 am, James Kanze <> wrote:


    [...]
    > I have a sequence of octets as mentioned in my earlier qs. I
    > have stored it in a vector which contains series of
    > octets.(uint_8*).


    If the vector is std::vector< uint_8* >, it contains a sequence
    of pointers, not a sequence of octets. You're still
    contradicting yourself, which is why we're having trouble
    understanding the problem.

    > I want to get the traverse through the series of octets from
    > offset=0 till the 6th element and compare with a mac address
    > that i have already in a string format(00:00:00:00:00:01->
    > converted to string-48,48,ascii:))). I want to use
    > strcmp/memcmp or something to compare once i extract 6 octets
    > from the offset=0 from the sequence of octets from vector. If
    > they are equal i want to do some operations. The octets are
    > read from a binary file. Could you please help me in this
    > regard? Some example code will be helpful for me.


    Until we know how and where these octets are stored, it's
    difficult to say much. If they are stored in a vector
    (std::vector< uint8_t >), then it's easy using std::copy or
    std::equal---I seem to remember having already posted the code.
    If they're stored somewhere else, then no one can answer until
    we know where they are stored.

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
    James Kanze, Apr 12, 2009
    #14
  15. Guest

    On Apr 12, 4:30 pm, James Kanze <> wrote:
    > On Apr 12, 7:18 am, wrote:
    >
    > > On Apr 11, 12:34 am, James Kanze <> wrote:

    >
    >     [...]
    >
    > > I have a sequence of octets as mentioned in my earlier qs. I
    > > have stored it in a vector which contains series of
    > > octets.(uint_8*).

    >
    > If the vector is std::vector< uint_8* >, it contains a sequence
    > of pointers, not a sequence of octets.  You're still
    > contradicting yourself, which is why we're having trouble
    > understanding the problem.
    >
    > > I want to get the traverse through the series of octets from
    > > offset=0 till the 6th element and compare with a mac address
    > > that i have already in a string format(00:00:00:00:00:01->
    > > converted to string-48,48,ascii:))). I want to use
    > > strcmp/memcmp or something to compare once i extract 6 octets
    > > from the offset=0 from the sequence of octets from vector. If
    > > they are equal i want to do some operations.  The octets are
    > > read from a binary file.  Could you please help me in this
    > > regard? Some example code will be helpful for me.

    >
    > Until we know how and where these octets are stored, it's
    > difficult to say much.  If they are stored in a vector
    > (std::vector< uint8_t >), then it's easy using std::copy or
    > std::equal---I seem to remember having already posted the code.
    > If they're stored somewhere else, then no one can answer until
    > we know where they are stored.
    >
    > --
    > James Kanze (GABI Software)             email:
    > Conseils en informatique orientée objet/
    >                    Beratung in objektorientierter Datenverarbeitung
    > 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34



    I fixed the problem extracting the 6 octets into a vector. Thanks for
    all your help. I have only one problem now. If I have a sequence of
    octets (1 0 94 0 0 2). I used std::copy and it worked. How will I make
    these to ASCII string?Could you please help me in this regard?
    , Apr 12, 2009
    #15
  16. Guest

    On Apr 12, 6:06 pm, wrote:
    > On Apr 12, 4:30 pm, James Kanze <> wrote:
    >
    >
    >
    > > On Apr 12, 7:18 am, wrote:

    >
    > > > On Apr 11, 12:34 am, James Kanze <> wrote:

    >
    > >     [...]

    >
    > > > I have a sequence of octets as mentioned in my earlier qs. I
    > > > have stored it in a vector which contains series of
    > > > octets.(uint_8*).

    >
    > > If the vector is std::vector< uint_8* >, it contains a sequence
    > > of pointers, not a sequence of octets.  You're still
    > > contradicting yourself, which is why we're having trouble
    > > understanding the problem.

    >
    > > > I want to get the traverse through the series of octets from
    > > > offset=0 till the 6th element and compare with a mac address
    > > > that i have already in a string format(00:00:00:00:00:01->
    > > > converted to string-48,48,ascii:))). I want to use
    > > > strcmp/memcmp or something to compare once i extract 6 octets
    > > > from the offset=0 from the sequence of octets from vector. If
    > > > they are equal i want to do some operations.  The octets are
    > > > read from a binary file.  Could you please help me in this
    > > > regard? Some example code will be helpful for me.

    >
    > > Until we know how and where these octets are stored, it's
    > > difficult to say much.  If they are stored in a vector
    > > (std::vector< uint8_t >), then it's easy using std::copy or
    > > std::equal---I seem to remember having already posted the code.
    > > If they're stored somewhere else, then no one can answer until
    > > we know where they are stored.

    >
    > > --
    > > James Kanze (GABI Software)             email:
    > > Conseils en informatique orientée objet/
    > >                    Beratung in objektorientierter Datenverarbeitung
    > > 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

    >
    > I fixed the problem extracting the 6 octets into a vector. Thanks for
    > all your help. I have only one problem now. If I have a sequence of
    > octets (1 0 94 0 0 2). I used std::copy and it worked. How will I make
    > these to ASCII string?Could you please help me in this regard?


    I have written the small program in VC++ and it gives lot of errors.
    Could you please help me in this regard?
    My objective is to convert the {1 0 94 0 0 2} which is stored in a
    vector to convert to ASCII string formatted MAC address.

    #include "stdafx.h"
    #include<iostream>
    #include<string>
    #include<vector>
    using namespace std;

    int main ()
    {
    vector<unsigned char> (pOctets);
    pOctets.resize(0);
    pOctets.reserve(6);
    pOctets.push_back("1");
    pOctets.push_back("0");
    pOctets.push_back("94");
    pOctets.push_back("0");
    pOctets.push_back("0");
    pOctets.push_back("2");

    unsigned char* buffer = new unsigned[6];
    const iterator it= pOctets.begin();
    int octet = 0;
    for (; it != pOctets.end(); ++it, ++octet)
    buffer[octet] = *it;

    char* buf = ConvertMacStringFromDecimal(buffer);


    }
    char*
    ConvertMacStringFromDecimal(unsigned char* buf) const
    {
    char temp[100];
    sprintf(temp,("%x:%x:%x:%x:%x:%x"),
    unsigned long ((buf >> 40) & 0xff),
    unsigned long ((buf >> 32) & 0xff),
    unsigned long ((buf >> 24) & 0xff),
    unsigned long ((buf >> 16) & 0xff),
    unsigned long ((buf >> 8) & 0xff)
    );
    return temp ;
    }


    Can somebody help me in this regard?

    >------ Build started: Project: test1, Configuration: Debug Win32 ------

    1>Compiling...
    1>test1.cpp
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(15) : error C2664:
    'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'const
    char [2]' to 'const unsigned char &'
    1> with
    1> [
    1> _Ty=unsigned char
    1> ]
    1> Reason: cannot convert from 'const char [2]' to 'const
    unsigned char'
    1> There is no context in which this conversion is possible
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(16) : error C2664:
    'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'const
    char [3]' to 'const unsigned char &'
    1> with
    1> [
    1> _Ty=unsigned char
    1> ]
    1> Reason: cannot convert from 'const char [3]' to 'const
    unsigned char'
    1> There is no context in which this conversion is possible
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(17) : error C2664:
    'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'const
    char [4]' to 'const unsigned char &'
    1> with
    1> [
    1> _Ty=unsigned char
    1> ]
    1> Reason: cannot convert from 'const char [4]' to 'const
    unsigned char'
    1> There is no context in which this conversion is possible
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(18) : error C2664:
    'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'const
    char [3]' to 'const unsigned char &'
    1> with
    1> [
    1> _Ty=unsigned char
    1> ]
    1> Reason: cannot convert from 'const char [3]' to 'const
    unsigned char'
    1> There is no context in which this conversion is possible
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(19) : error C2664:
    'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'const
    char [3]' to 'const unsigned char &'
    1> with
    1> [
    1> _Ty=unsigned char
    1> ]
    1> Reason: cannot convert from 'const char [3]' to 'const
    unsigned char'
    1> There is no context in which this conversion is possible
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(20) : error C2664:
    'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'const
    char [3]' to 'const unsigned char &'
    1> with
    1> [
    1> _Ty=unsigned char
    1> ]
    1> Reason: cannot convert from 'const char [3]' to 'const
    unsigned char'
    1> There is no context in which this conversion is possible
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(22) : error C2440:
    'initializing' : cannot convert from 'unsigned int *' to 'unsigned
    char *'
    1> Types pointed to are unrelated; conversion requires
    reinterpret_cast, C-style cast or function-style cast
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(23) : error C2514:
    'std::iterator' : class has no constructors
    1> c:\program files\microsoft visual studio 8\vc\include
    \xutility(486) : see declaration of 'std::iterator'
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::vector<_Ty,_Alloc> &,const
    std::vector<_Ty,_Alloc> &)' : could not deduce template argument for
    'const std::vector<_Ty,_Alloc> &' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include\vector
    (1268) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::vector<_Ty,_Alloc> &,const
    std::vector<_Ty,_Alloc> &)' : could not deduce template argument for
    'const std::vector<_Ty,_Alloc> &' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include\vector
    (1268) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::istream_iterator<_Ty,_Elem,_Traits,_Diff>
    &,const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &)' : could not
    deduce template argument for 'const
    std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &' from 'const
    std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include
    \iterator(277) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::istream_iterator<_Ty,_Elem,_Traits,_Diff>
    &,const std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &)' : could not
    deduce template argument for 'const
    std::istream_iterator<_Ty,_Elem,_Traits,_Diff> &' from 'const
    std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include
    \iterator(277) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::basic_string<_Elem,_Traits,_Alloc> &,const
    _Elem *)' : could not deduce template argument for 'const
    std::basic_string<_Elem,_Traits,_Alloc> &' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include\string
    (121) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::basic_string<_Elem,_Traits,_Alloc> &,const
    _Elem *)' : could not deduce template argument for 'const
    std::basic_string<_Elem,_Traits,_Alloc> &' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include\string
    (121) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const _Elem *,const
    std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce
    template argument for 'const _Elem *' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include\string
    (111) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::basic_string<_Elem,_Traits,_Alloc> &,const
    std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce
    template argument for 'const std::basic_string<_Elem,_Traits,_Alloc>
    &' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include\string
    (101) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::basic_string<_Elem,_Traits,_Alloc> &,const
    std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce
    template argument for 'const std::basic_string<_Elem,_Traits,_Alloc>
    &' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include\string
    (101) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::allocator<_Ty> &,const
    std::allocator<_Other> &) throw()' : could not deduce template
    argument for 'const std::allocator<_Ty> &' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include\xmemory
    (181) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::allocator<_Ty> &,const
    std::allocator<_Other> &) throw()' : could not deduce template
    argument for 'const std::allocator<_Ty> &' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include\xmemory
    (181) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::istreambuf_iterator<_Elem,_Traits> &,const
    std::istreambuf_iterator<_Elem,_Traits> &)' : could not deduce
    template argument for 'const std::istreambuf_iterator<_Elem,_Traits>
    &' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include
    \xutility(2152) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::istreambuf_iterator<_Elem,_Traits> &,const
    std::istreambuf_iterator<_Elem,_Traits> &)' : could not deduce
    template argument for 'const std::istreambuf_iterator<_Elem,_Traits>
    &' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include
    \xutility(2152) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::reverse_iterator<_RanIt> &,const
    std::reverse_iterator<_RanIt2> &)' : could not deduce template
    argument for 'const std::reverse_iterator<_RanIt> &' from 'const
    std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include
    \xutility(1834) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::reverse_iterator<_RanIt> &,const
    std::reverse_iterator<_RanIt2> &)' : could not deduce template
    argument for 'const std::reverse_iterator<_RanIt> &' from 'const
    std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include
    \xutility(1834) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::pair<_Ty1,_Ty2> &,const
    std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for
    'const std::pair<_Ty1,_Ty2> &' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include\utility
    (68) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2784: 'bool
    std::eek:perator !=(const std::pair<_Ty1,_Ty2> &,const
    std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for
    'const std::pair<_Ty1,_Ty2> &' from 'const std::iterator'
    1> c:\program files\microsoft visual studio 8\vc\include\utility
    (68) : see declaration of 'std::eek:perator !='
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2676: binary '!=' :
    'const std::iterator' does not define this operator or a conversion to
    a type acceptable to the predefined operator
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(25) : error C2675: unary '++' :
    'const std::iterator' does not define this operator or a conversion to
    a type acceptable to the predefined operator
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(26) : error C2100: illegal
    indirection
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(26) : error C2440: '=' : cannot
    convert from 'const std::iterator' to 'unsigned char'
    1> No user-defined-conversion operator available that can
    perform this conversion, or the operator cannot be called
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(28) : error C3861:
    'ConvertMacStringLong': identifier not found
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(34) : error C2270:
    'ConvertMacStringLong' : modifiers not allowed on nonmember functions
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(34) : error C2365:
    'ConvertMacStringLong' : redefinition; previous definition was
    'formerly unknown identifier'
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(37) : warning C4293: '>>' : shift
    count negative or too big, undefined behavior
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(37) : error C2296: '>>' : illegal,
    left operand has type 'unsigned char *'
    1>c:\documents and settings\soni\my documents\visual studio
    2005\projects\test1\test1\test1.cpp(37) : fatal error C1903: unable to
    recover from previous error(s); stopping compilation
    1>Build log was saved at "file://c:\Documents and Settings\soni\My
    Documents\Visual Studio 2005\Projects\test1\test1\Debug\BuildLog.htm"
    1>test1 - 34 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
    ==========
    , Apr 12, 2009
    #16
  17. SG Guest

    On 12 Apr., 17:18, wrote:
    > I have written the small program in VC++ and it gives lot of errors.
    > [...]


    [horrible piece of pseudo C++ code removed]

    > [...]
    > Can somebody help me in this regard?


    Sure. The kinds of posts you wrote imply that you
    - lack basic programming experiences (language agnostic)
    - don't understanding the basics of C++

    What to do about it?
    - get a book/tutor for learning the C++ language
    - get a book/tutor for learning programming

    As a bonus -- I feel generous today -- let me decipher a couple of
    compiler error messages for you:

    > 1>c:\documents and settings\soni\my documents\visual studio
    > 2005\projects\test1\test1\test1.cpp(15) : error C2664:
    > 'std::vector<_Ty>::push_back' : cannot convert parameter 1 from 'const
    > char [2]' to 'const unsigned char &'
    > 1>        with
    > 1>        [
    > 1>            _Ty=unsigned char
    > 1>        ]
    > 1>        Reason: cannot convert from 'const char [2]' to 'const
    > unsigned char'
    > 1>        There is no context in which this conversion is possible


    The literal "1" in push_back("1") is of type const char[2]. It's a
    char array containing the character for the decimal one and a
    terminating zero. Your vector stores unsigned char. There is no
    conversion from char[2] to unsigned char.

    In the case of push_back("94") the type of the argument is const char
    [3].

    etc

    > 1>c:\documents and settings\soni\my documents\visual studio
    > 2005\projects\test1\test1\test1.cpp(22) : error C2440:
    > 'initializing' : cannot convert from 'unsigned int *' to 'unsigned
    > char *'
    > 1>        Types pointed to are unrelated; conversion requires
    > reinterpret_cast, C-style cast or function-style cast


    You wrote

    unsigned char* something = new unsigned[6];

    "new unsigned[6]" is an expression that returns a pointer to an
    unsigned integer. You seem to have forgotten the "char" after
    "unsigned" in the new expression.

    > 1>c:\documents and settings\soni\my documents\visual studio
    > 2005\projects\test1\test1\test1.cpp(23) : error C2514:
    > 'std::iterator' : class has no constructors
    > 1>        c:\program files\microsoft visual studio 8\vc\include
    > \xutility(486) : see declaration of 'std::iterator'


    due to the line

    const iterator it= pOctets.begin();

    You used a using directive and pulled a lot of names into your global
    scope. One of those names seems to be "iterator" (std::iterator from
    the <iterator> header). This is NOT the iterator you want. In fact,
    std::iterator *is* no iterator. It's just a base class that contains
    some typedefs. You want to use your vector's iterator instead.


    Cheers!
    SG
    SG, Apr 12, 2009
    #17
  18. James Kanze Guest

    On Apr 12, 3:06 pm, wrote:
    > On Apr 12, 4:30 pm, James Kanze <> wrote:
    > > On Apr 12, 7:18 am, wrote:


    > I fixed the problem extracting the 6 octets into a vector.
    > Thanks for all your help. I have only one problem now. If I
    > have a sequence of octets (1 0 94 0 0 2). I used std::copy and
    > it worked. How will I make these to ASCII string?Could you
    > please help me in this regard?


    It depends. A priori, you'll use an ostream, but that's just a
    start. What is the format of the ASCII string? Where does the
    ASCII string go (in an std::string, to a file...)?

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
    James Kanze, Apr 13, 2009
    #18
  19. Guest

    On Apr 13, 2:56 pm, James Kanze <> wrote:
    > On Apr 12, 3:06 pm, wrote:
    >
    > > On Apr 12, 4:30 pm, James Kanze <> wrote:
    > > > On Apr 12, 7:18 am, wrote:

    > > I fixed the problem extracting the 6 octets into a vector.
    > > Thanks for all your help. I have only one problem now. If I
    > > have a sequence of octets (1 0 94 0 0 2). I used std::copy and
    > > it worked. How will I make these to ASCII string?Could you
    > > please help me in this regard?

    >
    > It depends.  A priori, you'll use an ostream, but that's just a
    > start.  What is the format of the ASCII string?  Where does the
    > ASCII string go (in an std::string, to a file...)?
    >
    > --
    > James Kanze (GABI Software)             email:
    > Conseils en informatique orientée objet/
    >                    Beratung in objektorientierter Datenverarbeitung
    > 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


    Hi all,
    Finally I succeed with my experiment ;). What I did is I extracted
    the 6 octets into a vector and then used ostream/istream. Thanks for
    your all your support. Special thanks to SG and James...
    , Apr 13, 2009
    #19
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chason Hayes

    Literal Escaped Octets

    Chason Hayes, Feb 6, 2006, in forum: Python
    Replies:
    11
    Views:
    674
    Chason Hayes
    Feb 8, 2006
  2. Replies:
    8
    Views:
    1,913
    Csaba
    Feb 18, 2006
  3. Stefan Ram
    Replies:
    8
    Views:
    1,677
    Karl Uppiano
    Jul 18, 2009
  4. Peter Vereshagin
    Replies:
    3
    Views:
    158
    Dr.Ruud
    Mar 17, 2011
  5. Ivan Shmakov
    Replies:
    5
    Views:
    377
    Ivan Shmakov
    Dec 12, 2011
Loading...

Share This Page