Yes, perhaps, if you can see Ain func(A is just a 1D double-indexed array, not a pointer to arrays, then why is this possible).
#include <stdio.h>
char A[100][100];
void func(void *ptr) {
char *ptrc = (char*)ptr;
printf("index %d\n",int((ptrc-A[0])/sizeof(A[0])));
}
int main()
{
char *ptr = A[5];
func(ptr);
}
result:
index 5
of course, if you pass an unbound pointer to func, you will get undefined results.
: void * char * .
EDIT: chqrlie , , ( , ):
#include <stdio.h>
#include <assert.h>
char A[100][100];
void func(void *ptr)
{
char *ptrc = (char*)ptr;
ptrdiff_t diff = (ptrc-A[0]);
assert(0 <= diff);
assert(diff < sizeof(A));
printf("index %d %d\n",(int)(diff/sizeof(A[0])),(int)(diff % sizeof(A[0])));
}
int main()
{
char *ptr = &(A[5][34]);
func(ptr);
}
:
index 5 34