by PC to 1000???????
struct Computer
{
char Manufacturer[30];
float Price;
int Memory;
} *PC;
int main (void)
{
struct Computer pc;
PC = %26amp;pc;
return 0;
}
a. PC-%26gt;Price=1000.0;
b. PC.Price=1000.0;
c. *PC.Price=1000.0;
d. Computer.Price=1000.0;
Given the structure and pointer, what assignment statement sets the Price member of the structure pointed to?
The answer is a).
PC is a pointer to a Computer.
To dereference a pointer, use -%26gt;.
Hence, the answer is PC-%26gt;Price = 1000.0;
You could also use (*PC).Price = 1000.0; however c) in the above example is wrong because it does not include brackets, which are required here.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment