inserting binary data in a STL List
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: inserting binary data in a STL List

  1. #1
    Join Date
    Feb 2009
    Posts
    243

    inserting binary data in a STL List

    inserting binary data in a STL List

    is that a good practice?


    typedef list<string, allocator<string> > LISTSTR;

    LISTSTR BL;

    how do would i insert a element with explicit lenght since binary data messes the null used to delimit c style strings...

    i ve heard that stl::strings stores the lenght explicily without the need of the null delimiter

  2. #2
    Join Date
    Apr 1999
    Posts
    27,424

    Re: inserting binary data in a STL List

    Quote Originally Posted by Alphadan View Post
    inserting binary data in a STL List

    is that a good practice?


    typedef list<string, allocator<string> > LISTSTR;

    LISTSTR BL;

    how do would i insert a element with explicit lenght since binary data messes the null used to delimit c style strings...

    i ve heard that stl::strings stores the lenght explicily without the need of the null delimiter
    Look at the the std::string interface.

    You can construct strings using a length argument, and you have the string::append() function to concatenate binary data.

    http://www.cplusplus.com/reference/string/string/
    http://www.cplusplus.com/reference/s...string/string/

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Feb 2009
    Posts
    243

    Re: inserting binary data in a STL List

    thx paul found the answer surfing in the net

    mylist.push_back(std::string(buff, bytesread));

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    Re: inserting binary data in a STL List

    There's also a vector<char> if you have any doubt.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center