Ask your own question, for FREE!
Computer Science 19 Online
OpenStudy (anonymous):

Could anyone explain me what is segmentation fault exactly? When I compile on Eclipse it works perfectly but on the submission page, online compiler, it gives segmentation fault. http://ideone.com/lqyPi

OpenStudy (anonymous):

Segfault is generally the program trying to access memory that it can't (or shouldn't in the first place). Also generally, the program produces a core dump file, to show that the core was dumped (no redundancy intended). This file can be used to debug, and one can use valgrind if the code is in C to check for such access violations. I think you can do the same with gdb, but my memory does not reach that far off. As for C++, I don't know of any tool to help with such cases(google might help here), but as a hint, segfaults often are caused by bad usage of pointers.

OpenStudy (anonymous):

Did you check my code? I think the problem is that, I checked many times but I didn't find any problem.

OpenStudy (anonymous):

For problems like segfaults... you may use gdb. I ran through your code with the exact same input as in the ideone.com paste, but no segfaulting. I compiled the code using the code::blocks MinGW compiler, and no warnings. How did you get any segfaults in the first place?

OpenStudy (anonymous):

@bmp Valgrind works with any language :-D

OpenStudy (anonymous):

Also, on the ideone.com page, it shows no errors :-D I think it raised the SIGSEGV because of the funky way it accepts input from stdin. I guess there's nothing to really worry about.

OpenStudy (anonymous):

I also compiled on Eclipse and couple online compilers but no error. When i submitted on interviewstreet.com , it says segmentation error.

OpenStudy (anonymous):

Possible errors could occur after the first prompt for input: if the user does not enter a valid number then the code goes wild!

OpenStudy (llib_xoc):

"Possible errors" agdgdgdgwngo reminds us that we should always check our program's inputs!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!