Hi,
I am having following code,

char str[] = "FULL MOON" 
printf("%c",*str);
printf(" for %s",str);

This gives output as F for FULL MOON
What exactly is happening inside the str,*str,str[] ? I am lost in the behavior of char array and char pointers. Kindly Help.:(

It all boils down to what you need. str points to the first character of the string *str is the first character of the string str[n] is the nth character of the string *str and str[0] are functionally equivalent

str[2]---v
      str ==> FULL MOON
        *str--^
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.