Vintion's blog

~夜黑路滑,社会复杂~

C语言中char *a与char A[]的区别

| Comments

C语言char s[] 和 char *s的区别

看如下的代码,区别立现

char *s = "hello world";
char s[] = "hello world"

区别在于前者是指针,后者是数组

char *s是一个指向只读区域的指针,只读区域是hello world
char s[]是一个数组,内容是拷贝了只读区别的数据

前者指针指向的内容不能变,后者可变


Comments