From: "André Luiz Moura" <aluizmoura@yahoo.com.br>
To: caml-list@inria.fr
Subject: [Caml-list] Value of the address of a pointer
Date: Fri, 20 Feb 2004 14:29:06 -0300 (ART) [thread overview]
Message-ID: <20040220172906.7855.qmail@web60603.mail.yahoo.com> (raw)
[-- 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 --]
next reply other threads:[~2004-02-20 17:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-20 17:29 André Luiz Moura [this message]
2004-02-24 15:19 ` Nuutti Kotivuori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040220172906.7855.qmail@web60603.mail.yahoo.com \
--to=aluizmoura@yahoo.com.br \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox