Save pointer's memory address
Storing the value of the pointer (i.e. the memory location of some variable) in a string can be done much like you've used printf:
char buf[128];void *s = malloc (size);sprintf(buf, "%p\n",s);
To 'save' the value into an integer (type) you can do a simple cast:
void *s = malloc (size);size_t int_value = (size_t)s;
Since in c you never know what your machine address pointer length is, this (technically) isn't guaranteed to work quite right; both of these methods can go wrong with wacky architectures or compilers.