如何在C ++中使用Vector存储Cstring [英] How to store Cstring using Vector in C++

查看:193
本文介绍了如何在C ++中使用Vector存储Cstring的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的C ++专家/专家,

我是C ++的新手,我的问题很基本,我需要将CString存储在Vector中,因为即使经过几次尝试我也不知道该怎么做,还是新手,请帮助我.我的代码如下:

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:

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");

}

推荐答案



看到此代码:
Hi,

see this code:
#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.


#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


这篇关于如何在C ++中使用Vector存储Cstring的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆