为什么我的输出中出现了分段错误? [英] why am i getting a segmentation fault in my output?

查看:128
本文介绍了为什么我的输出中出现了分段错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

展开 | 选择 | Wrap | 行号

推荐答案

将来您可以只发布与问题相关的代码。期望人们通过大量的代码筛选出你遇到问题的几行代码是不公平的。


另外,将来,请说明你拥有的内容问题,你得到了什么(如果有的话)错误,以及你试图解决问题的方法。不要只发布一堆代码,并希望我们弄清楚它是什么,它有什么问题,以及你遇到的问题。


请检查有关如何提出问题的详细信息,请参阅发布指南。



当程序试图访问不允许访问的内存位置或尝试以不允许的方式访问内存位置时发生分段错误(对于例如,尝试写入只读位置或覆盖操作系统的一部分。


这意味着您尝试访问代码中的某处您的应用程序不允许访问的内存。很可能你正在穿过一个阵列并越过它的末端...


-Frinny
In the future could you please only post the code that is relevant to the problem. It''s unfair to expect people to sift through tons of code to find the few lines that you are having problems with.

Also, in the future, please specify what you are having problems with, what (if any) errors you are getting, and what you have tried to solve the problem. Don''t just post a bunch of code and expect us to figure out what it is, what''s wrong with it, and what you are having problems with.

Please check out the posting guidelines for more information on how to ask a question.


A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (for example, attempting to write to a read-only location, or to overwrite part of the operating system).


This means that somewhere in your code you are attempting to access memory that your application is not allowed to access. It''s likely that you''re moving through an array and going past the end of it...

-Frinny


never记住我的帖子,重新提升你的代码,我的评论是不正确的。

尝试提供错误信息和行号,如果可能,帮助很多
never mind my post, reshifted your code and my comment was incorrect.
Try providing the error message and line number if possible, helps alot


检查char是否是默认签名或未签名


/ s / Jim WIlliams
check on whether char is signed or unsigned by default

/s/ Jim WIlliams


这篇关于为什么我的输出中出现了分段错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆