Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Gurus/Experts in C++,

I am new to C++.My Question is very basic.I need CString to be stored in Vector, as I am new even after several attempts I dont know how to do it.Kindly help me.My code is as below:

C++
void Editcontrol(CString prop1,CString prop2,CString prop3)
{
       Vector <string> v;

       //  I need to store CString in   Vector, even after many tries I                        could not able to do it                      
}


int main()
{
   Editcontrol("Haroon","Rizwan","Noor");

}
Posted
Comments
Jochen Arndt 7-Sep-12 3:09am    
Have a look at the CStringArray class. May be it is sufficient for your requirements.

Hi,

see this code:
C++
#include <vector>
using namespace std;

int main()
{
   Editcontrol(_T("Haroon"),_T("Rizwan"),_T("Noor"));
}

void Editcontrol(CString prop1,CString prop2,CString prop3)
{
  vector<CString> v;
  v.push_back(prop1);
  v.push_back(prop2);
  v.push_back(prop3);
}

I tested it and it works very well.
 
Share this answer
 
v3
Comments
Espen Harlinn 7-Sep-12 4:46am    
5'ed!
C++
#include <vector>
using namespace std;

void Editcontrol(CString prop1,CString prop2,CString prop3){
  vector<string> v;
  v.push_back(prop1);
  v.push_back(prop2);
  v.push_back(prop3);
}


should do the job
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900