- This topic has 0 replies, 1 voice, and was last updated 16 years, 6 months ago by .
Viewing 0 reply threads
Viewing 0 reply threads
- The forum ‘C Programming’ is closed to new topics and replies.
Home › Forums › C Programming › Delete an array on structure
Dear friends.
I composed an array on a structure and fill the structures. Then I tried to free it again with the free-function, but I still get an error under Visual Studio.
How do I do it correctly?
Here my code for allocating and filling:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | SoilVG=(struct soils*) malloc(pSo->iLayers*sizeof(struct soils));<br /> <br /> for(i=0; i<pSo->iLayers; i++)<br /> {<br /> SoilVG.alpha=pSo->pSWater->fVanGenA;<br /> SoilVG.Ks=pSo->pSWater->fCondSat;<br /> SoilVG.n=pSo->pSWater->fVanGenN;<br /> SoilVG.Theta_r=pSo->pSWater->fContRes;<br /> SoilVG.Theta_s=pSo->pSWater->fContSat;<br /> pSo->pSWater=pSo->pSWater->pNext;<br /> <br /> if(pSo->pSWater==NULL)<br /> break;<br /> }<br /> <br /> Next is the structure soils:<br /> struct soils<br /> {<br /> floatTheta_r;<br /> floatTheta_s;<br /> floatalpha;<br /> floatn;<br /> floatKs;<br /> }; |
and then I tried to free SoilVG with
free(SoilVG);
Thank you in advance.