I'm reading the contents of a .txt file into an array of char arrays. For some reason I'm getting a duplicate on the last entry, can anyone shed some light on this?
INPUT FILE: food.txt (this one is fine)
Candy
turkey
steak
potatoes
OUTPUT FILE: oFood.txt
Candy
turkey
steak
potatoes
potatoes <-----HERE I'm getting the duplicate, it's showing up as an extra in my char array, it's clobbering the bounds as well
Am I missing something? I don't see any bounds checking on r (starting on line 52.) When r == 4 (out of bounds), I bet it's printing the data in buffer. After r == 5, you're lucky it doesn't print junk.