0

ok short and sweet hopefully. suppose you have a struct like so

struct SomeName
{
     string id;
}

and you read data from a file into the id then you want to search for a specific id that has a relationship to a name

long findStudent (StudentList list, long count, string student)
{
	long n;

	//loop for finding a student in list
	for(n=0;n<count;n++)
    {
		temp=list.students[n];
        if(temp.id==student)
            return n;
    }

	//return count
	return count;
}

i obviously didnt provide all code but can if needed. its a basic search function im just unsure how to search through the struct with the dot operator.

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by n8makar
0

you mean this? if( list.students[n].id == student)

wow yes exactly. i should have known about the .id after students[n], but you helped me out big time. if we're keeping track thats twice now.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.