Hi.
I recently read that using the name of an array without brackets was one method for accessing the <address> of the array's first element. E.g:
#include <stdio.h>
int arr[5] = { 2, 4, 6, 8, 10 };
int main( void ) {
printf( "The address of the '2' is %d\n", arr );
return 0;
}
char* message1 = "C";
char* message2 = "is the";
char* message3 = "best";
char* message4 = "programming";
char* message5 = "language!";
puts( message1 );
puts( message2 );
puts( message3 );
puts( message4 );
puts( message5 );
/* message1 points to the 'C' and using puts (message1) will */
/* display the letter as opposed to the address. Why is this? */
/* I know the puts() function receives a char pointer as an */
/* argument. Is this why one need not dereference it by */
/* using *message1 unless one is using */
/* printf( "%c\n", *message1 ); */
/* Essentially, I'm slightly confused by when one pointer is */
/* pointing to the address of the first element in an array and when */
/* it is pointing to the first value */
return 0;
Thanks for the help,
java_girl