林每次我试图用Visual C++ 2008C++矢量推回错误
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace std;
void load(const char* filename) {
vector <string*> vec;
ifstream in(filename);
char buffer[256];
while(!in.eof()) {
in.getline(buffer, 256);
vec.push_back(new std::string(buffer));
}
}
int main(int argc, char* args[]) {
cin.get();
return 0;
}
调试这个时候得到一个错误,出现此错误
Compiling...
main.cpp
Linking...
main.obj : error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: __thiscall std::_Vector_const_iterator,class std::allocator > *,class std::allocator,class std::allocator > *> >::_Vector_const_iterator,class std::allocator > *,class std::allocator,class std::allocator > *> >(class std::basic_string,class std::allocator > * *,class std::_Container_base_secure const *)" ([email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected][email protected]@@Z)
E:\blabla\Debug\test2.exe : fatal error LNK1120: 1 unresolved externals
我究竟做错了什么?
好像你在混合调试和发布设置。代码应该工作。 –
在附注上,我建议使用矢量作为缓冲区,而不是char []。顺便说一句,代码为我编译,必须是您的项目设置。 –
Borgleader
你可以在VC++ 2010或2012上试试它,因为它适用于它们。 –