stringstream causing cl.exe compiler error

Viewed 21

I have a tiny bit of code that works great but causes MSVC 2019 cl.exe to go bonkers and not let me compile. I have tested by forcing it and the code works but in best practise, I thought I should try to rewrite the code to avoid this. The only problem is, I don'tknow what part of the code is causing the error.

Here is the code:

std::string somestring = "orange|apple|pear|lemon|pineapple"
std::string answer[20];

std::stringstream string_stream(somestring);  // creating string stream object
    int i = 0;            // declaring i and assign  to 0

    while (string_stream.good())   // loop will continue if string stream is error free
    {
        std::string a;
        getline(string_stream, a, '|');   //calling getline fuction
        answer[i] = a;
        i++;
    }

Any ideas on what is causing the problem or how to rewrite it to avoid it are appreciated. Here is the error although it does not tell me much.

 libcmt.lib(utility.obj) : error LNK2019: unresolved external symbol _is_c_termination_complete referenced in function __scrt_dllmain_uninitialize_c
 libcmt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_initialize referenced in function __scrt_initialize_crt
 libcmt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_uninitialize referenced in function __scrt_uninitialize_crt
 libcmt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_uninitialize_critical referenced in function __scrt_dllmain_uninitialize_critical
 libcmt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_thread_attach referenced in function __scrt_dllmain_crt_thread_attach
 libcmt.lib(utility.obj) : error LNK2019: unresolved external symbol __acrt_thread_detach referenced in function __scrt_dllmain_crt_thread_detach
0 Answers
Related