出於某種原因,每當我運行this program時,它將退出permute(permutater, length, lenth);
。當我註釋掉該行並且該函數甚至不運行時,這不會發生。任何幫助?程序意外退出原因不明(C++)
1
A
回答
10
我注意到的第一件事 - 你沒有初始化索引變量hor
。
int permute(string permutater,int length,int lenth)
{
int hor,hor2,marker;
cout << length/lenth;
for (marker=0;marker !=(length/lenth);marker++)
{
hor2 = permutater[hor]; // <== hor is not initialized
permutater[hor] = permutater[hor-1];
permutater[hor] = hor2;
hor--;
cout << permutater;
}
}
+0
這就是答案。任何舊垃圾都可能成爲廢物,指向任何舊的記憶。訪問該內存會造成很大的麻煩。案件結案。 –
+0
非常感謝,事後看來(一如既往),很明顯,-_-。感謝您支持我。 – Galileo
2
HOR2 =交換器[HOR];
hor
的值是多少?
2
我用MSVC
error C4716: 'permute' : must return a value
warning C4700: uninitialized local variable 'hor' used
0
沒有得到一個機會來運行它,但得到了下面的編譯錯誤,但你有沒有注意到,你在permute(string permutater,int length,int lenth)
功能缺失return
。
另外,請#include <string>
相關問題
- 1. 追蹤原因'應用程序意外退出'閃亮
- 2. 程序意外退出
- 3. 應用程序意外登出的原因是什麼?
- 4. selenium WebDriverException驅動程序意外退出
- 5. Windows Mobile應用程序意外退出
- 6. java.io.FileNotFoundExceptionis拋出原因不明
- 7. Win32線程意外退出
- 8. FastCGI進程意外退出
- 9. Javascript輸出原因意外令牌<
- 10. java.lang.RuntimeException:主線程循環意外退出,可能是什麼原因?
- 11. 應用程序崩潰,原因不明
- 12. 應用程序崩潰,意外,我不能閱讀的原因
- 13. Phonegap config.xml - 不明原因的意圖
- 14. C程序輸出的原因
- 15. 原因是C怪輸出++程序
- 16. 不明原因
- 17. C#Windows窗體應用程序意外退出,沒有錯誤
- 18. XQuartz意外退出
- 19. Xcode意外退出
- 20. MPMoviePlayerViewController意外退出
- 21. lxde意外退出
- 22. LaunchDaemon意外退出
- 23. 外部約束失敗原因不明
- 24. 在C#/ WCF應用程序中使用原因不明的CPU
- 25. C++ libpthread程序段錯誤原因不明
- 26. Qt5 C++應用程序崩潰原因不明
- 27. 爲什麼我的PyQt4程序沒有明顯的原因退出主循環?
- 28. 退出C程序
- 29. 應用程序退出並且很難找到原因
- 30. LinqDataSource拋出一個ChangeConflictException,原因不明
你有可能使用調試器試過嗎? –
它似乎是導致段錯誤,我認爲這與指針有關? – Galileo