【发布时间】:2015-01-22 22:41:18
【问题描述】:
如何将 a 中的字符串与向量中的值进行比较<:string>?
我试了str,下面打印错误。
.....
vector<std::string> dat;
vector<std::string> pdat;
dat = my();
for(int b = 2; b < dat.size(); b+=7){
// cout << dat[b] << " " << endl;
if(!strcmp(dat[b], "String\n"){ // The error is here
pdat.push_back(dat[b]);
}
}
my.cpp:在函数'std::vector > ngr()'中:
my.cpp:53:32:错误:无法将参数 '1' 转换为 '__gnu_cxx::__alloc_traits > >::value_type {aka std::basic_string}' 为 'const char*' 到 'int strcmp(const char*, const char*)'
【问题讨论】: