hello,
i want to sort a file and i don't know how to put the data from a certain field of the file in a vector, sort it and then put it back in the file.
here's what i've done.
FILE *file;
struct catalog{char 1rst_field,2nd_field,3rd_field}name,v[100];
//here i put the data in the file
typedef int(*fcmp)(const void*,const void*)
cmp1rst_field(catalog a1,catalog a2)
{return a1.1rst_field-a2.1rst_field}
int a[100],n=100,i;
void sort()
{
while(!feof(file))
//here i'd have to put the data from 1rst_field in a[i];i++;
qsort(&a[0],n,sizeof (int),(fcmp)cmp1rst_field)
}
i'd appreciate any help with this sorting algorithm or another that would be simpler.thank you.