I am trying to sort the Structure by author and title
when i try to sort it by author it will only let me sort
the author and not the title with it.
so, when i sort by author the title is wrong.
heres what i have:
Code:struct Library { string Title; string Author; }; const int ARRAY_SIZE = 1000; Library books [ ARRAY_SIZE ];now I would imagineCode:void SortByAuthor( int count ) { string temp; for ( int index = 1; index < count; index++ ) { for( int i = 0; i < count; i++ ) if(books[i].Author > books[index].Author) { temp = books[i].Author; books[i].Author = books[index].Author; books[index].Author = temp; } }
I would want to do this:
to copy the whole struct but, i get errors.Code:if(books[i].Author > books[index].Author) { temp = books[i]; books[i] = books[index]; books[index] = temp; }
whats wrong?Code:1>error C2679: binary '=' : no operator found which takes a right-hand operand of type 'Library' (or there is no acceptable conversion)
thanks in advance.



LinkBack URL
About LinkBacks


