The program keeps on crashing when it finishes case 1
The program keeps on crashing when it finishes case 1
Use code tags next time, and its this piece of code
Code:scanf("%d", amount1); // Missing '&' before variable amount1
I cant believe I missed that. Thank you.
The problem has one more problem when it attempts to subtract the requests from the donations. It will take out the donations and reset the donations to 0, but the requests will remain the same and not subtract the amount of donations from it
Post the relevant code in code tags...
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
> I cant believe I missed that. Thank you.
Try using a compiler with lots of warnings.
If you always do this and only run code with zero warnings, you'll fix all the dumb stuff before having to stare at the screen wondering why it's crashed again.Code:$ gcc -c -Wall foo.c foo.c: In function `main': foo.c:45: warning: format argument is not a pointer (arg 2) foo.c:45: warning: format argument is not a pointer (arg 2) foo.c:97: warning: statement with no effect foo.c:102: warning: statement with no effect foo.c:114: warning: statement with no effect foo.c:120: warning: statement with no effect foo.c:132: warning: statement with no effect foo.c:138: warning: statement with no effect foo.c:150: warning: statement with no effect foo.c:156: warning: statement with no effect foo.c:168: warning: statement with no effect foo.c:174: warning: statement with no effect
You'll instead be staring blankly at the screen wondering what the interesting bug is that you'll have to find
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Yes,when I wanted to learn something new and compiled and started a bunch of codes(arrays,pointers)I always forgot the & and program crashes when it gets to that function. I also got stuck on: file dFILE;-you are suppose to write file as FILE - I kept getting an error in compiler