*
pcnate@gmail.com:[color=blue]
> I've been having some problems with pointers and such.This is homework,
> so I don't want people writing codeand telling me to use it. I just
> want some direction on what isn't working.
>
>
> here is the structure prototype:
> struct Books
> {
> string ISBN;
> string title;
> string author;
> string publisher;
> float price;
> int onHand;
> };[/color]
Are you sure this is a prototype of a collection of Books, and not a
single Book?
It looks like a single Book to me.
[color=blue]
> here is the call:
> swapElems(book, startscan, minIndex);[/color]
If you defined 'book' etc. then perhaps it could tell others something.
[color=blue]
> book is the struct, startscan is an int for the subscript, and so is
> minIndex
>
> here is the func with lines in question:
> swapElems(Books *x, int startscan, int minIndex)
> {
> Books temp = { "", "", "", "", 0.0f, 0 };
>
> temp = *x[startscan];
> *x[startscan] = *x[minIndex];
> *x[minIndex] = temp;
> }[/color]
The best advice is to NOT USE RAW POINTERS or raw arrays until you gain
much more experience.
To represent a collection of books, do something like
std::vector<Book> books;
or
std::vector<Book> books(500);
To swap e.g. the books at indices 5 and 13, do
std::swap( books.at(5), books.at(13) );
[color=blue]
> I get the four errors that say illegal indirection and the compiler is
> MS visual studio 2003, not that it even matters. I need to do this, but
> more importantly, I need to learn it TOO.[/color]
Use the standard library, as explained above.
Keep away from pointers and raw arrays.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?