简体   繁体   English

代码没有在 DEV C++ 上运行但在 Visual Studio 上完美运行的任何原因?

[英]Any reasons for code not running on DEV C++ but running perfectly on Visual Studio?

So my code compiles on Dev C++ but when it runs, it gives a blank output screen for a few seconds then the program terminates.所以我的代码在 Dev C++ 上编译,但是当它运行时,它会给出一个空白的 output 屏幕几秒钟然后程序终止。 The code on Dev shows no errors or warnings. Dev 上的代码没有显示错误或警告。 It works perfectly on VS.它在 VS 上完美运行。 I have tried re-installing Dev but that doesn't work.我已经尝试重新安装 Dev 但这不起作用。 I know Dev is outdated but i'm forced to check my code on it since its a project and will be checked and graded on Dev.我知道 Dev 已经过时,但我不得不检查我的代码,因为它是一个项目,并且将在 Dev 上进行检查和评分。 I did not feel like posting the whole code since it is around 400 lines but since it might or might not help in understanding the problem, i have attached it.我不想发布整个代码,因为它大约有 400 行,但由于它可能有助于也可能不会帮助理解问题,所以我附上了它。 I don't know which part might cause this issue so i've attached the whole thing.我不知道哪个部分可能会导致这个问题,所以我已经附上了整个东西。 I hope you don't mind.我希望你不要介意。 This is my first post here so if I've made any mistakes in asking a question please let me know.这是我在这里的第一篇文章,所以如果我在提问时犯了任何错误,请告诉我。 Thanks.谢谢。

Thank you so much to @LouisGo and @molbdnilo for the help.非常感谢 @LouisGo 和 @molbdnilo 的帮助。 I've found the reason for the segmentation error in Dev C++ through debugging.我通过调试找到了Dev C++中出现分段错误的原因。 This part: *hashArray = NULL;//SET ARRAY INDEXES TO NULL was the problem.这部分: *hashArray = NULL;//SET ARRAY INDEXES TO NULL是问题所在。 Dev C++ doesn't allow initializations in this way while VS does. Dev C++ 不允许以这种方式进行初始化,而 VS 允许。 So I had to initialize it this way:所以我不得不这样初始化它:

for(int i=0; i<20; i++)
        {
            hashArray[i]=NULL;
        }

It works fine now.它现在工作正常。

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

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