Connecting Tech Pros Worldwide Forums | Help | Site Map

difference between?

Newbie
 
Join Date: Jun 2009
Posts: 8
#1: Jun 30 '09
in c (and/or) c++ what is the difference between variables declared as: char[] and char*?

thanks

Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,188
#2: Jun 30 '09

re: difference between?


Start by reading this.
Expert
 
Join Date: Mar 2008
Location: Naperville, Illinois U.S.
Posts: 831
#3: Jul 1 '09

re: difference between?


In C ...

If you're talking about the difference between function parameters declared as char[] or char*, then I would say there is absolutely no difference of any kind.

If you're talking about the difference between variables declared as char[N] or char * (where N is an integer), then one additional difference not mentioned in Banfa's link is that sizeof(char[N]) is N, but sizeof(char*) is the size of a pointer.
Reply