Hi,
I have been asked to create a small programme that asks a user how many students information they would like to enter and then asks the user to enter all their information storing it all into a struct.

The above is all good I know exactly know how to do this, but then we have to ask the user to seacrh for a student record using the student ID where they are then shown the record of that particular student.
Student ID will be an element in the struct. I am not sure exactly how to go about this!
Any help would be appreciated.
Thanks

What about a linked list?
Or alternatively, you could store all the class instances in an array with as many elements as the the user inputs, and to check which instance has the student's ID run a loop through all the indexes.
An example to make it all clearer:

...
struct StudentInfo
{
...
unsigned int ID;
...
}

int main(void)
{
short int NumOfStudents;
cout<<"Input information on how many students?\n";
cin>>NumOfStudents;
StudentInfo Students[NumOfStudents];
short int Index;
   for(Index=0;Index<NumOfStudents;Index++)
   {
   ... // input students information
   }

unsigned int ID_ToLookFor;
cout<<"Search for a student with what ID?\n";
cin>>ID_ToLookFor;
   for(Index=0;Index<NumOfStudents;Index++)
   {
   if(Students[Index].ID==ID_ToLookFor) .. // do whatever you need to do here
   }
...
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.