From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA25632; Fri, 20 Feb 2004 18:29:10 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA26318 for ; Fri, 20 Feb 2004 18:29:08 +0100 (MET) Received: from web60603.mail.yahoo.com (web60603.mail.yahoo.com [216.109.118.223]) by concorde.inria.fr (8.12.10/8.12.10) with SMTP id i1KHT7ae012421 for ; Fri, 20 Feb 2004 18:29:07 +0100 Message-ID: <20040220172906.7855.qmail@web60603.mail.yahoo.com> Received: from [200.137.225.200] by web60603.mail.yahoo.com via HTTP; Fri, 20 Feb 2004 14:29:06 ART Date: Fri, 20 Feb 2004 14:29:06 -0300 (ART) From: =?iso-8859-1?q?Andr=E9=20Luiz=20Moura?= Subject: [Caml-list] Value of the address of a pointer To: caml-list@inria.fr MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-2099931439-1077298146=:7788" Content-Transfer-Encoding: 8bit X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; printf:01 printf:01 W8:99 ocaml:01 ocaml:01 int:01 int:01 config:02 W5:97 W5:97 address:96 address:96 pointer:03 pointer:03 array:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk --0-2099931439-1077298146=:7788 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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! --0-2099931439-1077298146=:7788 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit
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! --0-2099931439-1077298146=:7788-- ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners