Segmentation fault (core dumped) Error

强颜欢笑 提交于 2019-12-04 15:24:46
scale == 'c' || 'C'

does not do what you think it does. It parses like this:

( scale == 'c' ) || 'C'

and 'C' is always true. If you had compiler warnings enabled, you should have noticed this.

(No, this is not your immediate problem; it's up at the end of get_temps. But with warnings enabled, you would have seen that too.)

Attach a debugger and step through your code. It's possible you are dividing by 0 or running past the end of an array. At the very least we need more info before we can help.

Are you compiling on a linux machine? If so, Valgrind is a great tool for diagnosing segmentation fault errors.

What does error do? If it's not throwing an exception, then code that calls it will keep going with bogus data.

cin >> name; only reads a "word" from the standard input, not a whole line. So if there are spaces in the file name, your program won't get the correct file name.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!