You cannot do pointer arithmetic in standard Fortran. You have to rely on the processor dependent binary correspondence between pointers and integers.
Also, there are no unsigned integers in Fortran.
type(c_ptr) :: start,ref
integer(c_int) :: res
start = c_loc(my_struct%a)
ref = c_loc(my_struct%b%c)
res = int( transfer(start, 1_c_intptr_t) - transfer(ref, 1_c_intptr_t) , c_int)
There may be problems, if the pointer values are larger, than the maximum positive value for the signed c_intptr_t
.