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

有帮助吗?

解决方案

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*));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top