r/cprogramming • u/[deleted] • Apr 24 '21
Need help with this code, Its giving garbage value
1
u/zCybeRz Apr 24 '21
If the array is size 10, the maximum index is 9. You could change the value passed in to h-1, but it's more common to pass in the size and use < instead of <= when iterating it
0
2
u/atsju Apr 24 '21
I found the (or at least one big enough to cause issues) error. As I said in first post, you access array outside it's boundaries. Check them better. I won't tell you exactly where because it wouldn't help you in long term.
So find out how to use a debugger because you will need it in long term and it will really help you more than the answer. Programming is more like 90% debugging and testing.
Edit : I really don't want to be mean by not giving the answer right away. Do not hesitate to ask if you are still struggling in some hours.
1
u/ptchinster Apr 24 '21
!picoftext
1
u/rtlcprogbot Apr 24 '21
!picoftext
For the love of fuck dont give us a picture of text.
I am a bot. Replying to me notifies nobody




13
u/atsju Apr 24 '21
Seriously, don't share print screens. And please what is the problem ? Expectations VS results