Question

I am trying to store data from a CSV file and ran into an access violation. The first image was shows how the memory is allocated, the second shows the problem area and the third is the spot in the csv where the problem occurred. Any help is appreciated.

enter image description here snip of my VS

data at problem location

Was it helpful?

Solution

It looks like the first loop that does the "pre-allocation" may have an error. The following allocation:

AllCurrentData[newLineCOunt].data = malloc(COLUMNS * sizeof(char));

should, I believe, be this:

AllCurrentData[newLineCOunt].data = malloc(COLUMNS * sizeof(char*));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top