View Single Post
Join Date: Aug 2008
Posts: 77
Reputation: mahlerfive is an unknown quantity at this point 
Solved Threads: 16
mahlerfive mahlerfive is offline Offline
Junior Poster in Training

Re: Pointer arrays and structures

 
0
  #2
Nov 28th, 2008
You have allocated space for all of the studentInfo pointers here (except the last one, you should not be subtracting 1):
  1. struct studentInfo *students[numOfStudents-1];

But, you have not allocated space for the actual studentInfo structures that each pointer will point to. To do that you will have to make a loop that allocates a studentInfo for each pointer using malloc().

Something like:
  1. students[i] = (studentInfo*) malloc( sizeof(studentInfo) );
Reply With Quote