okay im supposed to read from a file and store data in a struct array ,but i must insert in place at the time of reading.i have sucessfully read from the file just my insertion function needs some help. this is what i have so far
Code:
//struct declaration
typedef struct{
char fname[15];
char lname[15];
int accnum;
double balance;
}Account;
//how i call it
fscanf(in,"%d",&temp);
while(temp!=-1){
type[i].accnum=temp;
fscanf(in,"%lf %s %s",&type[i].balance,&type[i].fname,&type[i].lname);
insertinplace(type[i],type,0,1000);
i++;
fscanf(in,"%d",&temp);
}
//function
void insertinplace(Account set,Account list[MAX],int m,int n){
int k=n;
while(k>=m && set.accnum < list[k].accnum){
list[k+1]=list[k];
--k;
}
list[k+1]=set;
}
i just need a little -> in the corect direction.thanks for any help i can get