Pointers and struct |
WorkerT w; WorkerT *wp; wp = &w; // a problem ... *wp.salary = 125000.00; // does not have the same effect as w.salary = 125000.00; // because it is interpreted as *(wp.salary) = 125000.00; // to achieve the correct effect, we need (*wp).salary = 125000.00; // a simpler alternative is normally used in C wp->salary = 125000.00; |
Learn this well; you will see it many more times this semester.