This is an exercise that involves calculating the sum and the product of 2 polynomials. if it has a structure and a pointer within one example:
how can we access the pointer? what do you recommend?Code:typedef struct (
int a;
int * a;
P);
p p1;
Printable View
This is an exercise that involves calculating the sum and the product of 2 polynomials. if it has a structure and a pointer within one example:
how can we access the pointer? what do you recommend?Code:typedef struct (
int a;
int * a;
P);
p p1;
declare two variables (pointer or not) with the same name ..
To access:
- The value of the pointer (address): p1.t
- The value of the variable pointed to: p1-> t OR (* p1). T
- The value of the variable p1.a
- The address of the variable & p1.a
So, if t points to a:
p1.t == & p1.a
p1-> t == p1.a
A Polynomial in the variable X, of Degree n, has the form: aX^n+bX^(n-1)+...+vX^2+wX+z, where (a),(b),(v),(w),and (z) are Real numbers, (n) is a Whole number, and (a)is not equal to zero, the typedef means you no longer have to write struct all over the place.
- The value of the variable pointed to: p1-> t OR (* p1). T
If the pointer is p1.t, the value of the variable is pointing * (p1.t). Writing p1-> * t or (p1). T is legitimate only if p1 is a pointer to a structure of type p, which is not the case.
Same. * (p1.t) == p1.aCode:p1.t == & p1.a
p1-> t == p1.a