c - why does it make sense that indexing a character pointer is an int?
- by hatorade
char *a = "apple";
printf("%s\n", a); \\ fine
printf("%s\n", a[1]); \\ compiler complains an int is being passed
Why does indexing a string pointer give me an int? I was expecting it to just print the string starting at position one (which is actually what happens when i use &a[1] instead). why do i need to get the address?