Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   (BEGINNERS)Possible REASONS for Unexpected program termination. (http://www.go4expert.com/forums/beginners-reasons-unexpected-program-t28836/)

jose_peeterson 5Aug2012 23:41

(BEGINNERS)Possible REASONS for Unexpected program termination.
 
This post is for BEGINNERS only!
hey guys,
I am doing a small project currently and by experience i have figured out some possible reasons for why a program might quit unexpectedly without giving errors.

Please ignore the details, only sift through to know the reasons behind the errors. thank you.


1)
Program terminates unexpectedly because of not typing in 5 strings for ADD Items or OLD saved items in items.txt does not have 5 typed strings in the same line.
This happens all because strtok is called when the sentence less than 8 strings has no strings for strtok() to chop.

2)
Program terminates unexpectedly or cannot load from text file to structure. The problem is the string length allocation. Don't forget to include the null terminating character into the length of the string.
3)
Program terminates unexpectedly because of %S not being supplied with string.
e.g. printf("\n>> %s is NOT in the ITEM Records");

4)
ERROR: cannot convert `bool' to `const char*' for argument `1' to `int strcmp(const char*, const char*)'

if(strcmp((item_call_no,(item[i]).call_no) == 0) && (strc("hello",(item[i]).availability) == 0)) solution: have to use nested if one after another, == 0 for both stcmp
5)
Program terminates unexpectedly because the string to CONCATENATE/COPY is NOT Cleared.
Use string1[0] = '\0' to clear.


All times are GMT +5.5. The time now is 20:12.