I'm posing this problem to you guys because it seems that the entire computer science department is stumped by the following.
The arcatecture of the processor is SPARC, and it's running SunOS 5.8.
here's the code:
here's the output:Code:#include <iostream> using std::cout; using std::endl; using std::cin; int main() { signed int * ptr1, * ptr2; signed int array1[10]; ptr1 = array1; ptr2 = &array1[0]; cout<<ptr1<<endl; cout<<ptr2<<endl; return 0; }
Why is this wierd? Well according to ANSI C++ when you declare an array the actually name of the array with out an index value, (e.g. array1) is supposed to be a pointer which points to array1[0]. The problem is that in an x86 system, the above code would return two different addresses, one address for the pointer of array1 and one address for the location of the contents of array[0]. Can anyone explain this?Code:bash-2.03$ ./a.out 0xffbef988 0xffbef988
Thank you