c++ - How to dereference pointer when pointee value assigned in response -


i want dereference pointer firsm->rootfolder->totalitemsinview takes value, when response arrived.

ns1__messagetype* messgt = new ns1__messagetype(); std::vector<ns1__messagetype> v; int count;  ews__finditemresponsemessagetype *firsm = new ews__finditemresponsemessagetype(); firsm->rootfolder = new ns1__finditemparenttype(); count = *firsm->rootfolder->totalitemsinview;  for(int i=0; < count; i++){     v.push_back(messgt[i]);     std::cout << "hello"  << std::endl; } 

totalitemsinview defined in class of ns1__finditemparenttype.

class ns1__finditemparenttype { public:        int* totalitemsinview ; }; 

here totalitemsinview have integer value in response of soap request. want use integer value in count run 'for loop' many times.

in compilation i've got segmentation fault may because of empty value @ totalitemsinview, in response have value, how can that. i'm new pointers, appreciated. thank you.

update: xml received log:

<m:finditemresponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">     <m:responsemessages>         <m:finditemresponsemessage responseclass="success">             <m:responsecode>noerror</m:responsecode>             <m:rootfolder totalitemsinview="2" includeslastiteminrange="true">                 <t:items>                     <t:message>                         <t:itemid id="b30rtzmma5" changekey="cqaaabaaaaawl"/>                     </t:message>                     <t:message>                         <t:itemid id="tnfsaaaifua" changekey="cqaaaaaawt"/>                     </t:message>                 </t:items>             </m:rootfolder>         </m:finditemresponsemessage>     </m:responsemessages> </m:finditemresponse> 

i wrong here @ firsm->rootfolder = new ns1__finditemparenttype() tried initialize response structure empty value, that's way i've problem in derefrencing it. thr right way is

ews__finditemresponsemessagetype *firsm = new ews__finditemresponsemessagetype(); firsm = finditemres.ews__finditemresponse->responsemessages->__union_arrayofresponsemessagestype->union_arrayofresponsemessagestype.finditemresponsemessage; count = *firsm->rootfolder->totalitemsinview; 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -