caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Value of the address of a pointer
@ 2004-02-20 17:29 André Luiz Moura
  2004-02-24 15:19 ` Nuutti Kotivuori
  0 siblings, 1 reply; 2+ messages in thread
From: André Luiz Moura @ 2004-02-20 17:29 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1030 bytes --]

Hello,
 
Please, it would like to know as to get in OCaml the value of the address of memory of a pointer, as it occurs in the example in C that follows:

Code:
void main()
{
   int my_array[] = {1, 23, 17};
   int *ptr;
   int i;
 
   ptr = &my_array[0];         /* point  to the first element of the array */
   for (i = 0; i < 3; i++) {
      printf("\nvalue of my_array[%d] = %d; ", i, my_array[i]);
      printf("value of ptr + %d = %d\n",i, *(ptr + i)); 
      printf("address of my_array[%d] = %x; ", i, &my_array[i]);
      printf("address of ptr = %x\n", (ptr + i)); 
}
 
Result:
value of my_array[0] = 1; value of ptr + 0 = 1
address of my_array[0] = 12ff80; address of ptr = 12ff80
 
value of my_array[1] = 23; value of ptr + 1 = 23
address of my_array[1] = 12ff84; address of ptr = 12ff84
 
value of my_array[2] = 17; value of ptr + 2 = 17
address of my_array[2] = 12ff88; address of ptr = 12ff88
 
Thanks,
 
André
 





---------------------------------
Yahoo! Mail - O melhor e-mail do Brasil. Abra sua conta agora!

[-- Attachment #2: Type: text/html, Size: 1587 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-02-24 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-20 17:29 [Caml-list] Value of the address of a pointer André Luiz Moura
2004-02-24 15:19 ` Nuutti Kotivuori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).