I am sorry but it is two years or more since I do not program in C. I probably do not
remember the syntax properly, anyway I think that the idea was correct. In addition,
when programming in C we have to bear in mind the compiler we are using (there are
some subtle differences).
Brian, try the next piece of code in C which represents the same idea:
#include <stdio.h>
int main(){
int foo[40];
int *foo2;
foo2 = (int *)&foo;
foo[0] = 1;
foo[1] = 2;
printf("%d",*foo2);
foo2 = foo2 + 1;
printf("%d", *foo2);
exit(0);
}
Regards
Rafa
-----Original Message-----
From: Brian P Bohnet <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Date: Wed, 10 Mar 2004 10:30:53 -0600
Subject: Re: thanks rafa
Your code is incorrect, you cannot manipulate an array that way, see
error produced:
: operator + cannot be applied to char[],int
foo = foo + 1;
^
Rafael Tolosana wrote:
> I will try it with two simple examples:
>
> First have a look at this Java code:
> String foo = new String("Example String");
> String foo2 = foo;
>
> Now have a look at this C code:
> char[] foo = "Example String";
> char[] foo2 = foo;
> foo = foo + 1;
>
> In the first example we have two references to the same object String,
> but you cannot manipulate the memory address of the references. On the
> other hand, in the second example we have two pointers to the same
> memory zone and the foo variable has been incremented by one, so that
> it will point to "xample String".
>
> I hope this will help you understand
>
> Rafa
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant archives, FAQs and Forums on JSPs can be found at:
http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com
-------------------------------
"Vulnerant omnes, ultima necat"
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant archives, FAQs and Forums on JSPs can be found at:
http://java.sun.com/products/jsp
http://archives.java.sun.com/jsp-interest.html
http://forums.java.sun.com
http://www.jspinsider.com