Hi guys, I was told to create a program using compound data structure in order to store and display student details. It runs fine, until it reaches the end, then a windows error message appears "searching for a solution to my problem" and it returns a random huge number.
The problem is that there is no fnam[10].. If you recall declaring an array of 10 elements you put 10 like fname[10] //etc.. but all elements are only 0-9 .
in your for loop when variable i reaches 10 it would mean that you will save the file in the 10th element but the only element is available from 0-9 (10 elements) meaning if i is equal to 10 then you will save it in the 11th element which is none-existent. Thus you will have an error.
Arrays start at 0, not 1. Hence, writing to fnam[10] or any other spot at 10 is invalid since you are writing to unallocated memory, which has unforseen consequences.