Friday, July 31, 2009

C++ Question?

I have a vector of structs. The struct contains a string and int variable.





I take in the information like this:





while(check != true)


{


cout %26lt;%26lt; "Name: ";


cin %26gt;%26gt; DataInfo.info;





if(DataInfo.info == "-99")


check = true;





cout %26lt;%26lt; "Phone Number: ";


cin %26gt;%26gt; DataInfo.data;





if(DataInfo.data == -99)


check = true;





Vector.push_back(DataInfo);





}








Ok simple right. Whats the best way to print the contents??





I tried the copy function from the %26lt;algorithm%26gt; header file but it wont work on vectors of structs.





Any Ideas?

C++ Question?
for(int i=0; Vector.size(); i++)


cout%26lt;%26lt; Vector[i].info %26lt;%26lt; "-" %26lt;%26lt; Vector[i].data %26lt;%26lt;endl;
Reply:TRY


system.out.println(" " )


No comments:

Post a Comment