i have struct
struct bookinfo { char title[50]; int numauthors; char authors[50][50]; int year; int checkedout; }; i can sorted years cannot sort titles life of me code print out names in order in file or "incompatible types in assingment" errors comented lines
int j,i; char temp; for(i = 1; < 14; i++) { j = - 1; while( j >= 0 && strcmp( library[j+1].title, library[j].title) < 0 ) { temp = library[j + 1]; /*errors*/ library[j+1] = library[j]; library[j] = temp; /*errors*/ j--; } printf("n%s",library[j].title); } what doing wrong here?
you sorting bookinfo instances, temp variable should of same type instead of char:
int j,i; bookinfo temp;
Comments
Post a Comment