Advertisement
Guest User

Untitled

a guest
Mar 27th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. /*
  2. there are some rules to know about pointer assingments and 'const'. it's valid to assign the address of either constant data or non-constant data to a pointer-to-constant:
  3. */
  4.  
  5. double rates[5] = {88.99, 100.12, 59.45, 183.11, 340.5};
  6. const double locked[4] = {0.08, 0.075, 0.0725, 0.07};
  7.  
  8. const double *pc = rates;       //valid
  9. pc = locked;                    //valid
  10. pc = &rates[3];                 //valid
  11.  
  12. // why is the deref symbol '*' used at var declaration but not at subsequent assignments?
  13. // ex const double *pc;
  14. // ex *pc = locked;
  15. // ex *pc = &rates[3];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement