Hello. I wrote this program and it has problems in the purchase function. It's meant to give the user an option of what to buy and ask the user how much of a certain product does he/she wants to buy and then do the calculations and display how much money the user has left. I tried to solve it but without any luck plus i'am a bit stuck on this problem and I cannot write the next part of my program untill I overcome this problem. The compiler keeps saying uknown field and I don'nt really understand what it means by it. I would appriciate any help.

Ok this is your ninth thread about this program. On one occasion
i solved a problem of yours and the code worked, and it appears
that each following thread you are making modifications that you
dont understand and introducing new errors into the code. My
advice is to learn the language. Try getting a reputable book or
a tutorial and really study because some of the errors in your
code are so fundamental that it is really worrying.

What compiler are you using? If you dont understand your
compiler error messages, either look up your documentation,
or get a better compiler. Both compilers i use show up the
following errors:

Quote:

in function int DisplayPort(Goods_g*,Ports_p*,Float*):
struct Goods_g has no member named "Fish"
struct Goods_g has no member named "Cotton"
struct Goods_g has no member named "Wood"
.
.
.
.
in function int Purchase(Goods_g*,float*,float):
struct Goods_g has no member named "Fish"
struct Goods_g has no member named "Cotton"
struct Goods_g has no member named "Wood"

See the problem?

Here is your definition of Goods_g:

Code:

typedef struct{
char Goods[20];
}Goods_g;

now stick with me because this is the start of your trouble.
Goods is a character array (string). it is the only member within the struct.

in main you declare an array of structs, type Goods_g.
you initialise the members as follows:

ask yourself, what is happening here? you are declaring 10
structs of type Goods_g, and you are intitialising the members
of that array, 1 member per array, to names you have chosen.
essentially what the above code does is set the Goods string
in the 0 element of the Goods_g array to the string literal "Fish"
the 1 element gets its member set to "Cotton".
See the pattern?

Now thats all good and well, that works. Then later, you call
DisplayPort, and you pass the memory address of one of those
elements of the array of structs to the function.

DisplayPort ( &G[k-1], &P[i-1], variables);

the problem with that is that "k" is a variable and it is uninitialised
at this point in the program so even if the next point which i will
make was correctly coded by you, that function call would mess
it up. Lets assume that you were passing element 0 of the
array of structs. Here is the motherload of a problem
which you have created:

when you pass the address of that element, you can manipulate
its members using the pointer you have set up (i.e. the string
Goods). The problem you have created in the above code is
that you are trying to the access member Fish, the member
Cotton, and so on.

NONE OF THESE ARE ACTUALLY MEMBERS OF THAT BLOODY
STRUCT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

the address you passed, points to a string, you initialised that
string to "Fish". to break it down as simply as possible,
you passed a pointer to an array of characters containing the
word Fish. Fish is not a member of the struct, neither is Cotton.
the only member is the array that contains the
string literal Fish!

Do you see the problem??? None of that code make a wink of
sense in any language. Now i could go into even more detail
for you but i neither have the time nor the patience to explain
any further. Just learn how to program and learn from this,
at least in a small way that your code is remarkably ,
fundamentally, and morally wrong. It will never be right.
the reason that no-one responded to your last thread in a helpful
manner is because you code is so wrong that it would take so
long to explain to you what is wrong. I wasn't even gonna reply
myself but i thought it only fair for you to get some form of
feedback on your code. i dont mean to sound offensive, but
what i have said is the truth as i see it