Didn't know if this will help but I made a couple changes to MK27's example to show exactly what the memory addresses look like and how subtracting response from p gets the index number.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FALSE 0
#define TRUE 23
int main(int argc, char **argv)
{
int i;
char * response = "hello world", *p =response;
int size = strlen(response);
for( i=0;i<size;i++) {
printf("%p %c index is:%d\toffset of p:%d %p \t",response,*p,i,p-response,p);
printf("(p-response) = %d\n",p-response);
p++;
}
return 0;
}
/*
0x8048590 h index is:0 offset of p:0 0x8048590 (p-response) = 0
0x8048590 e index is:1 offset of p:1 0x8048591 (p-response) = 1
0x8048590 l index is:2 offset of p:2 0x8048592 (p-response) = 2
0x8048590 l index is:3 offset of p:3 0x8048593 (p-response) = 3
0x8048590 o index is:4 offset of p:4 0x8048594 (p-response) = 4
0x8048590 index is:5 offset of p:5 0x8048595 (p-response) = 5
0x8048590 w index is:6 offset of p:6 0x8048596 (p-response) = 6
0x8048590 o index is:7 offset of p:7 0x8048597 (p-response) = 7
0x8048590 r index is:8 offset of p:8 0x8048598 (p-response) = 8
0x8048590 l index is:9 offset of p:9 0x8048599 (p-response) = 9
0x8048590 d index is:10 offset of p:10 0x804859a (p-response) = 10
*/