I wrote a program that breaks a string when the corresponding delimiter occurs. But another error occurs, for example:
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
I tested the same program in dev C ++ and it works fine, but in the visual studio these problems occur.
My program:
#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;
}
I even tried to remove the title and change the main () function to int main () and int main (void). But the same error occurs in the visual studio. Please help me.
source
share