Difference between pointer and array

来源:互联网 发布:湖北网络爆料平台 编辑:程序博客网 时间:2024/06/06 01:29

逛stackoverflow无意发现的,很常见的错误,自己就曾迷糊过,你是否也曾犯过?:-)

Can anybody tell me difference between the bellow statements?
 

ANS:When you declare char p[] you are declaring an array of chars (which is accessible to be both read and written), and this array

is initialized to some sequence of characters i.e. "This is test" is copied to the elements in this array.

When you declare char* p, you are declaring a pointer that points directly to some constant literal - not a copy. These can only

be read.

 

原创粉丝点击