I'm a beginner at learning c. But I don't know the whether the str is a pointer variable or an array. If str is a pointer variable then why does the first printf works? It prints out the hole string ''Information'', and the second printed out ''ation''.
#include <stdio.h>
int main ()
{
char *str = "Information";
printf("%s\n", str);
printf("%s\n", str+6);
printf("%c\n", *(str+6));
printf("%c\n", str[6]);
return 0;
}
Here is what I thought the program will write like:
#include <stdio.h>
int main ()
{
char str[15] = "Information";
char *a = str;
printf("%s\n", str);
printf("%s\n", str+6);
printf("%c\n", *(a+6));
printf("%c\n", str[6]);
return 0;
}