简体   繁体   English

C++,系统无法执行指定的程序

[英]C++, The system cannot execute the specified program

so I am new to C++ and recently I have been playing around with structures.所以我是 C++ 的新手,最近我一直在玩结构。 I have this code below.我在下面有这个代码。 This does not give me an error when I compile it but when it runs, it says "The system cannot execute the specified program."这在我编译时不会给我一个错误,但是当它运行时,它说“系统无法执行指定的程序”。 I have no idea why.我不知道为什么。 I tested this code on my friend's computer and it works for him and when I deleted a member variable inside the struct the code runs perfectly.我在我朋友的计算机上测试了这段代码,它对他有用,当我删除结构中的成员变量时,代码运行完美。 Also, when I initialize the object right before the ;另外,当我在 ; 之前初始化对象时in the end of the struct, my code works.在结构的末尾,我的代码有效。 But only with this specific layout my code doesn't work.但只有使用这种特定布局,我的代码才不起作用。 I am not really sure why this is wrong.我不确定为什么这是错误的。 Thanks!谢谢!

#include <iostream>
using namespace std;

struct bob {
  int num1;
  int num2;
  int num3;
};

int main() {    
   cout << "Sup" << endl;
   bob test; 
   test.num1 = 10;
   test.num2 = 20;
   test.num3 = 30;
   return 0;
}

I hope you have found a solution to this problem so far.Still I would like to share my experience.我希望到目前为止你已经找到了解决这个问题的方法。我仍然想分享我的经验。 I had the same problem , when I was trying to execute my c program's executable file in windows 10 pc.当我尝试在 Windows 10 pc 中执行我的 c 程序的可执行文件时,我遇到了同样的问题。 Then I came up with the idea to uninstall the antivirus which were restraining the executable file to execute.然后我想出了卸载限制可执行文件执行的防病毒软件的想法。 eventually that was the solution of this problem.最终这就是这个问题的解决方案。

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

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