How to implement a buffer by using stream

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • scudsong
    New Member
    • Mar 2008
    • 4

    How to implement a buffer by using stream

    Hi all,
    I'm writing a C++ program calculating MD5 hash.
    Let say it contains foo1() and foo2()
    which foo1() outputs data to unsigned char* buf with lenght "buflen".
    I'd like to store buf in somewhere (not in a file) rigth after foo1() ends each time.
    After few foo1() run few times(1~20 times), foo2() calculates all output of foo1() which already store sequencely somewhere.
    By the way, foo2() reads unsigned char * type if I change type during storing output of foo1().

    Please give me some advice, thanks!
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Use a vector of foo1() results:

    [code=cpp]
    struct results
    {
    char* buf;
    unisgned int buflen;
    };
    [/code]

    foo1() creates a result variable which you push_back() into a vector<results> .

    Later, foo2() can process the vector.

    Comment

    Working...