#include
/* const usage
* const int *a= b; //b is not variable, do not change b via a.
* int * const a = b //a is not variable, do not change a.
* const int * const a = b //a and b are not variable
*/
int main(int argc, char *argv[])
{
int str[4] = {1,2,3,4};
int str_dif[4] = {5,6,7,8};
const char *a = "abc";
*a = 4; //error: assignment of read-only location
int * const p = str;
p = str_dif ; // error: increment of read-only variable ‘p’
const int * const q = str; //combine up 2
return 0;
}
阅读(766) | 评论(0) | 转发(0) |