c指针中的const修饰符

// TEST.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

int main(int argc, char* argv[])
{
	const char **p;			/*指向const char* 的指针*/
	const char *q;
	char *i;
	 char *b;
	char * const *k=&i;		/*指向char*的指针,k指向  的内存单元   的内容不可改写*/
	char **const j=&i;		/*指向char*的指针,j所指向的内存单元不能 修改*/

	 (*k)="abcd";			/*修改(*k)的内容,error*/
	
		j=&b;				/*修改j所指向的内存单元 error*/			
		
	  (*j)++;
	q="aaaa";
	p=&q;
	(*p)++;

//	char* q=*p;				/*将const char* 赋值给非const的指针,error!*/

	printf("%s!\n",*p);
	return 0;
}

 

posted @ 2012-07-17 15:59  猪肉包子  阅读(143)  评论(0编辑  收藏  举报