I have a basic pointer question.
I have some code like this:
Please let me know if anything is wrong in the following code:
struct abc {
int a;
int b;
};
void func2(int*); // defined elsewhere
void func1 (struct abc *p1)
{
struct abc var1 = *p1; // ======> Can I do this ?
func2(&var1.b);
func2(&p1->b); // =========> Which of these 2 is right ?
}
Yes, this copies the struct pointed by p1 in the local variable var1.
Both, if
func2()accepts aint*as parameter. It depends if you wantfunc2to modifyp1->borvar1.b.