P
pcnate
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;
};
here is the call:
swapElems(book, startscan, minIndex);
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;
}
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.
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;
};
here is the call:
swapElems(book, startscan, minIndex);
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;
}
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.