简体   繁体   中英

Using “string” header file gives error in c++ on Windows 10

So I recently upgraded Windows 8.1 to Windows 10. I didn't faced this type of error before but when I program in c++ and include "string" header file then it pops out an error when executing though compiling does not give any error. I tried using "cstring" and update Microsoft Visual C++ Redistributable but no change. If I don't use "string" header file then it will not produce any error.

Here is test.cpp

#include <iostream>
#include <string>

using namespace std;

int main(){
   string text = "Hello World!";
   cout << text;
   return 0;
}

On compiling it does not give error

g++ test.cpp -o test.exe

But when I tried to execute via console it doesn't print anything. And when I tried to execute by double clicking "test.exe" then it showed me this

在此处输入图像描述

Finally I found what causes this error. There was a faulty app which is set in my system path variable containing a faulty libstdc++-6.dll which causes this error. I remove the path from th system path variable and now everything working fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM