林每次我試圖用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上試試它,因爲它適用於它們。 –