简体   繁体   English

使用“字符串”header 文件在 Windows 10 上的 c++ 中出现错误

[英]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. 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.我尝试使用“cstring”并更新 Microsoft Visual C++ Redistributable 但没有变化。 If I don't use "string" header file then it will not produce any error.如果我不使用“字符串”header 文件,那么它不会产生任何错误。

Here is test.cpp这是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当我尝试通过双击“test.exe”来执行时,它向我展示了这个

在此处输入图像描述

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.在我的系统路径变量中设置了一个错误的应用程序,其中包含导致此错误的错误 libstdc++-6.dll。 I remove the path from th system path variable and now everything working fine.我从系统路径变量中删除了路径,现在一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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