dynamic arrays, stucts and reading from files
Posted on 2004-10-10
Sorry for the vagueness of the title but ive got one of those problems...
Ok...im trying to read in from a file line by line and split each line up into seperate strings and then store the data in a struct.
basically ive got a function(tokeniser) which takes the stucture and the line and splits up and stores the data.
array = malloc(sizeof(structure) *numberOfLines());
while(fgets(line, 99, file))
Now this sort of works...it reads in around half the the file into the structure which i can print out as i wish. However around half way through the while loop it just stops. Running debug it gives:
Unhandled exception at 0x7c93793d in test.exe: 0xC0000005: Access violation writing location 0x00030ffc.
There is no problem with the file im reading as it is of uniform format all the way through.
So i assume there is something wrong with the array structure.
But as it works for part of the file i am clueless as to what is wrong.
Any suggestions as to what is wrong...or alternative solutions would be very much appreciated.