获取错误
tryout.cpp:29: error: no matching function for call to 'std::list<char, std::allocator<char> >::push_back(std::string&)'/opt/csw/gcc4/lib/gcc/sparc-sunsolaris2.8/4.0.2/../../../../include/c++/4.0.2/bits/stl_list.h:773: note: candidates are: void std::list<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = char, _Alloc = std::allocator<char>]
尝试使用参数将.text文件推送到列表中然而它不会推送 代码在下面
int main (int argc, char* argv[])
{
string vowels;
list<string> myList;
ifstream infile(argv[1]);
//open the file
if (infile.is_open() && infile.good()) {
while (infile.get(vowels))) {
myList.push_back(vowels));
infile.close();
return 0;
}
答案 0 :(得分:0)
int main(int argc, char* argv[]){
char vowels;
list<char> myList;
ifstream infile(argv[1]);
if (infile.is_open() && infile.good()) {
while (infile.get(vowels)) myList.push_back(vowels);
infile.close();
}
return 0;
}