Visual Studio 2015 & 2017 doesn't recognize std

Elinor Ginzburg 106 Reputation points
2020-08-25T04:58:53.277+00:00

Hello,

I've written simple piece of code which compiles and works perfectly on any other program which can compile and run C++,

but when I try to run it from VS 2015 on my laptop or on VS 2017 from my other laptop, it won't build it - I get an error saying it doesn't recognize std e.g. it says "string is not a member of std"

I've checked and I think that I've installed all necessary extensions for C++ to work.

How can I fix it?

Thank you.

Developer technologies | C++
Developer technologies | Visual Studio | Other
Community Center | Not monitored
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    1 deleted comment

    Comments have been turned off. Learn more

  2. WayneAKing 4,931 Reputation points
    2020-08-25T07:03:38.34+00:00

    Show a small but complete example of code that produces that error.

    Also be sure that you have the right #include statement:

    #include <string>
    
    • Wayne
    0 comments No comments

  3. Elinor Ginzburg 106 Reputation points
    2020-08-25T11:16:17.48+00:00

    the code:

    std::ostringstream ss;
    int i = 7;
    
    ss << std::hex << std::showbase << i;
    
    std::string str = ss.str();
    
    const char *output = str.c_str();
    
       
    

    the headers I've included:

    #include <stdlib>
    #include <iostream>
    #include <sstream>
    #include <iomanip>
    #include <string>
    #include <strstream>
    

    I also get an error "cannot open source file "stdlib""


  4. Jeanine Zhang-MSFT 11,356 Reputation points Microsoft External Staff
    2020-08-26T01:56:35.407+00:00

    As far as I'm concerned, you should use "#include<stdlib.h>" instead of "#include<stdlib>".

    And I agree with RLWA32, you could try to use "#include <cstdlib>". It includes the C Standard library header <stdlib.h> and adds the associated names to the std namespace. For more details I suggest you could refer to the Doc:<cstdlib>.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.