C語言筆記-const(2)

這是一個在網路上或書上常看到的:


  • int const
  • int const*
  • int *const
  • int *const*
  • int const**
  • int const*const*
要讀這種宣告就是由右往左讀:


  • int const=一個常數整數
  • int const*=指向一個常數整數的指標
  • int *const=指向一個整數的常數指標
  • int *const*=一個指向常數指標的指標,常數指標指向一整數
  • int const**=一個指向指標的指標,指標指向常數整數
  • int const*const*=一個指向常數指真的指針,常數指針指向常數整數

int const 可以寫成const int