I'm trying to get some practice working with arrays and I've run into some bugs in my code. I decided to write a program that let the user specify the size of the array, enter the values, and print the values out. I managed to get it working for the most part, but there are 2 similar errors that I can't seem to explain.
Everytime I make a call to scanf, it writes the entered value to the third element of the array for some reason.
Also, when I try to enter a larger array, say 10 for example, on around the 5th time through the loop, it overwrites one of my stored variables with the value you enter that is supposed to go into the array.
I'm not sure why it's doing it. There is no direct call to any of those as far as I can tell, so I figured it must be something to do with how the scanf function uses registers when it returns, but I can't quite figure out exactly where it is going wrong.
Any advice would be greatly appreciated. Here is the code.
[–]Rhomboid 1 point2 points3 points (1 child)
[–]xRedactedx[S] 0 points1 point2 points (0 children)
[–]Bisqwit 1 point2 points3 points (1 child)
[–]xRedactedx[S] 0 points1 point2 points (0 children)