<div dir="ltr">Hi Mudasir<br><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>//for MyVector<br></div><div><span style="font-family:monospace,monospace">std::vector<std::string> myTempVector = this->getMyVector();<br>    totalLength += encoder.prependByteArray(<br>            reinterpret_cast<uint8_t*>(&<wbr>myTempVector), sizeof(myTempVector));<br>    totalLength += encoder.prependVarNumber(<wbr>sizeof(myTempVector));<br>    totalLength += encoder.prependVarNumber(tlv::<wbr>MyVector);</span></div></div></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>//for MyVector</div><div><span style="font-family:monospace,monospace">val = m_wire.find(tlv::MyVector);<br>if (val == m_wire.elements_end()) {<br>    BOOST_THROW_EXCEPTION(Error("<wbr>MyVector element is missing"));<br>}<br>std::vector<std::string> myTemVector;<br>if (val->value_size() != sizeof(myTemVector)) {<br>    BOOST_THROW_EXCEPTION(Error("<span style="font-family:monospace,monospace">m<wbr>yTemVector</span> element is malformed"));<br>}<br>std::memcpy(&myTemVector, val->value(), sizeof(myTemVector));<br>m_MyVector = myTemVector;</span></div><div><br></div><div><b>Problem:</b> I'm following these 1-to-5 steps in order to add an Integer and a std::vector<std::string> fields in Interest packet but it gives an error on <b><span style="font-family:monospace,monospace">wireDecode</span></b> while decoding MyVector field and simulation stops and terminates. But it does not give error on MyInteger field. Am I doing it right? Am I missing something? Please help me solving this I'm stuck on this point from many days.</div></div></blockquote><div><br></div><div>You did not <a href="https://en.wikipedia.org/wiki/Serialization">serialize</a> the std::vector<std::string>, but merely copied the header structure of std::vector<std::string>. Thus, you triggered undefined behavior in STL library.</div><div><br></div><div>Learn to write the following two programs in C++:</div><div><ol><li>Given a std::vector<std::string>, write it to a file.</li><li>Read the above file into a std::vector<std::string>, and print it on screen.</li></ol></div><div>After you wrote these programs, you can use the same technique to write to and read from TLV structures.</div><div><br></div><div>Yours, Junxiao</div></div></div></div>