【发布时间】:2017-03-15 04:45:55
【问题描述】:
我编写了一个程序,可以在出现相应的分隔符时拆分字符串。但是发生了一个不同的错误,例如:
Error 1 error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: char const & __thiscall std::_String_const_iterator<class std::_String_val<struct std::_Simple_types<char> > >::operator*(void)const " (??D?$_String_const_iterator@V?$_String_val@U?$_Simple_types@D@std@@@std@@@std@@QBEABDXZ) Source.cpp Using Object_Type Input
我在 dev c++ 中测试了相同的程序,它运行良好,但在 Visual Studio 中,这些类型的问题正在引发。
我的计划:
#include <string>
#include <iostream>
#include<tchar.h>
using namespace std;
#pragma comment (lib, "ws2_32.lib")
int _tmain(int argc, _TCHAR* argv[])
{
string s = "Enter a line of text,\n next line\n as the\n delimiter: ";
string delimiter = "\n";
size_t pos = 0;
string token;
while ((pos = s.find(delimiter)) != std::string::npos) {
token = s.substr(0, pos);
std::cout << token << std::endl;
s.erase(0, pos + delimiter.length());
}
std::cout << s << std::endl;
return 0;
}
我什至尝试删除标题 并将 main() 函数更改为 int main() 和 int main(void)。但同样的错误发生在视觉工作室。请任何人帮助我。
【问题讨论】:
标签: c++ c++11 visual-studio-2012