As you may notice in the main, I have commented out the for() loop because, uncommented, it seems to generate a segmentation error each time it is compiled in and run, and I cannot seem to work out why.
Could you please advise me why this is the case and is there a solution?