edit : ^^^ Title should be referring to a struct pointer, ty Stiltskin
Could someone explain to me what happened at the line with a.ptr = &a. It seems the compiled version showing the solution is using a.ptr = a.num so therefore a.num = 50+1Code:struct foo{ int num; char *word; struct foo *ptr; }; void func1(struct foo); void func2(struct foo*); void func3(struct foo); int main(){ ... ... a.ptr = &a; a.num = 50; a.word = "mylastword"; func3(a); printf("4 %d %s\n", a.num, a.word); ... } void func3(struct foo a) { if(a.num > a.ptr->num) { a.num = 500; } else { a.num = a.ptr->num + 1; } a.word = "myotherword"; a.ptr->word = "yetanotherword"; printf("3 %d %s\n", a.num, a.word); }
the printf prints 3 51 myotherword
did a.ptr take the following lines value?



LinkBack URL
About LinkBacks



