I have finished my first year at college and i took one c++ programming course. I am having a summer training and i am asked to consider the main things that would make a program crash, such as a very large number input or character input istead of a decimal input. I just want to know how to avoid those main crashes.
Crashin in c++ programs!!!?
a program always crashes if you do something which is prohibited, either by hardware or by software.
hardware/software (operating systems) usually assign memory regions to a running process. The most common crash (a segmentation fault) happens when you try to access memory which is not assigned to your process. This happens i.e. when you use a pointer which is not properly initialized - maybe because you forgot error checking or have a bug in your program.
Another thing forbidden by the hardware is i.e. the division by zero.
in all those cases, the processor or the operating system send a signal to your application, and if the application does not handle the signal, it's terminated. this is usually referred to as a "crash".
Reply:try this link
http://www.google.co.uk/search?hl=en%26amp;sa=...
Reply:Read the input in a fixed length string and then convert to integer using atoi() function. Check for error code after conversion.If the conversion failed then you can notify the user about wrong input and quit.
Reply:The use of pointers is something lots of programmers have problems with.
Buffer overflows are another source of problems.
Implicit, incorrect casts...
And not to forget, something as simple as division by zero.
alstroemeria
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment