یه برنامه با استراکچر نوشتم ولی نمیدونم چجوری یه تابع جستجو براش بنویسم
include 
include 
include 
using namespace std;
define tedad   2
define n   10//name
define n_f 20//family
define n_d 15//dars
define nds   30//name dars
int searchstu( int, student);
struct student 
{
    char name[n],family[nf];
    char namedars[nd];
    int id;
    int tedaddars;
    int vaheddars;
    float nomre_dars;
    float ave;
};
int main()
{
    int i,j,id_stu;
    float m,s;
    student st[tedad];
    ofstream stu("stu system.txt");
    if(! stu)
    {
        cout<<" CAN NOT OPPEN FILE! ";
        return 0;
    }
for(i=0;i<tedad;i++)
{
    cout<<"moshakhasat daneshjo "<<i+1<<" :"<<endl;
    cout<<"NAME :  "<<endl;
    cin>>st[i].name;
    cout<<"\nFAMILY :"<<endl;
    cin>>st[i].family;
    cout<<"\nID :"<<endl;
    cin>>st[i].id;
}//end for i
//  system("cls");
////////////////////////////////////////////////
    cout<<"\nENTER ID STUDENT :"<<endl;
    cin>>idstu;
    int searchstu(st[].id,idstu);
        cout<<"\nTEDAD DARS :"<<endl;
        cin>>st[i].tedaddars;
        m=0;
        s=0;
        for(int j=0;j<st[i].tedaddars;j++)
        {
            cout<<"_______________________________________"<<endl;
            cout<<"DARS "<<j+1<<" :"<<endl;
            cout<<"\nNAM DARS  :"<<endl;
            cin>>st[j].namedars;
            cout<<"\nVAHED DARS :"<<endl;
            cin>>st[j].vaheddars;
            m+=st[j].vaheddars;
            cout<<"\nNOMRE DARS :"<<endl;
            cin>>st[j].nomredars;
            s=s+(st[j].nomredars*st[j].vahed_dars);
    }//end j
    st[i].ave=s/m;
    cout<<"\nMOADEL "<<i+1<<":"<<st[i].ave<<endl;
stu.close();
system("pause");
return 0;
}
int search_stu( int id,int idstu)
{
    int i=-1;
    while(++i<tedad)
        if(student.id==idstu)
        return 0;
    return -1;
}
به این تابع ایراد میگیره